I have a list with the names of several files:
file1
file2
I would like to add at the end of the 1st line of each file the name of the file e.g.:
file 1 first row will be
> ATCGCCfile1
file 2 first row will be
> ATTTCCfile1ATTTCCfile2
My idea is now to create a variable a with the file names' name:
a="file1 file2"
loop over the files and add the word re-calling the index:
for i in $a; do cat $i | awk '{print $0"$i"}' > $i.extended_word.txt; done
however in the output the awk '{print $0"$i"}' does not work and gives me just the $i without the name of the file e.g. in case of the 1st file >ATCGCC$i .
What am i doing wrong? I also tried the parentesis ( awk '{print $0"${i}"}') but without succeed.