awk give filename from another file

April 3, 2012 at 07:51:21
Specs: Linux i686
I have a data file, which contains one line. It is a filename. I want awk to read this out from the file and make an other file, which has the name the previous one contains. How could I make this?
filename: xy.dat
it contains: abc.fits
So awk should read this and make a file named: abc.fits
How can I do this? I tried it with the built-in variable: FILENAME but it didn't work.


See More: awk give filename from another file

Report •

April 3, 2012 at 21:07:08
Why do you insist on using awk? A simple touch command will create the file:


touch $(< xy.dat)

But if you insist:


awk ' { print "" >> $0 } ' xy.dat

Report •

April 5, 2012 at 07:15:51
Thank You!

After a few hours I posted the question, I found the 'touch' command... I'm only a beginner.

Report •

April 9, 2012 at 05:05:14
You can also use the cat command to achieve this.

filename=$(cat xy.dat)

Report •
Related Solutions

Ask Question