Entering edit mode
5.1 years ago
someler
•
0
I have a file with 50 lines of sample names. I have use this awk one liner before, but today, it only prints out the 50th line of the file. I expect this command to print all sample names ("Sample1", "Sample2", "Sample3", "Sample4"), but it doesn't. Can anyone help me figure out why? File example and command below.
Command:
SHORT=`echo $FILE | awk -F "_" '{print $1}'`
Sample1_F.txt
Sample2_R.txt
Sample3_F.txt
Sample4_R.txt
When I print this command to a file I only get "Sample4".
this can hardly be the complete command you try to execute. Can you also post the remainder? (eg. what is
$FILE
?)It's not. I was trying to not have to make my entire script anonymous. This is the beginning of my script to add read groups:
It should be running this for all 50 samples, but only does it for the last one.
Please use the formatting bar (especially the
code
option) to present your post better. I've done it for you this time.Thank you!
Woops! Thank you, I will next time.
Are you sure its the last line and not the first one? Maybe the newline is wrong. Think about what the awk actually does. (edit misread statement).
100% positive it is only printing the last line.
what does:
give as output?
This echoes all my lines. This surprised me because when I do this command it prints the last line. When I run my fill script, it returns a bam file with read groups to the last sample from that file. Confused about where the disconnect is.
that is strange indeed. With me it does print all entries to the output file. Your output looks more like what you would get with this command:
If your script is a loop in loop kinda system, can you check you did not put the done in the wrong place?
which shell (version?) are you using btw?