Reputation: 503
I have 22 files named with numbers that go to 1 to 22. Like:
bla.chr1.bla.norm
bla.chr2.bla.norm
etc...
I made a simple awk script to add on the first column that particular number of the filename:
for i in {1..22}
do
awk '{print "'"$i "'" $0}' *.chr${i}.*.norm > *.chr${i}.*.norm.chr
done
But now I want to save all the files using the wildcard I used before. Is it possible?
Upvotes: 0
Views: 409
Reputation: 1456
Try this, gawk
awk '{match(FILENAME,"chr([0-9]+).",t); print t[1] $0 > FILENAME".chr"}' *.norm
Upvotes: 2