awk give filename from another file

April 3, 2012 at 07:51:21
Specs: Linux i686
Hi.
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?
Example:
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.

Thanks!


See More: awk give filename from another file

Report •

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

#!/bin/bash

touch $(< xy.dat)

But if you insist:

#!/bin/bash

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


Report •

#2
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 •

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

#!/bin/sh
filename=$(cat xy.dat)


Report •
Related Solutions


Ask Question