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
> ATTTCCfile2
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.
>? Do you always have a space after the>? That isn't standard, or required by the fasta format. More importantly, how many files do you have? Do you even need a loop? If you do, can we just dofor f in *and get all the files of interest, or should that befor f in *faor something else? Can you show us the output oflsin the target directory and tell us what files should be modified?lsin the directory with your files and indicate which ones should be changed. Can we just dofor file in *fa; do...to get all files? And where does theATTTCCcome from? Do you want us to add something from the sequence line or the ID line? Can you show us an example file?file2is supposed to beATTTCCfile2