Hi, there
I have a file with tab and space as field separator. I need to assign values to variables then work with them, line by line. The code I wrote only works when each line has only one word. It doesn't work for the current situation.
for line in `cat file.txt`; do
ID=`awk '{print $NF}' $line`
START=`awk -F"\t" '{print $4}' $line`
END=`awk -F"\t" '{print $5}' $line`
...more works with these three variables...
done
I also try something like this, still not working:
cat file.txt | while read line; do
ID=`awk '{print $NF}' $line`
START=`awk -F"\t" '{print $4}' $line`
END=`awk -F"\t" '{print $5}' $line`
...more works with these three variables...
done
Can you please help me? Thanks!
cat file.txt
213 length:6407 abc xyz 2 343 . + 0 id 3290
213 length:6407 def mno 453 3922 . + 0 id 3291
......
the desire result (not printing them out, but assign to variables and then work with the variables) is:
for line 1, $ID=3290, $START=2, $END=343, and I will do a bunch of works with these variables before next line...
for line 2, $ID=3291, $START=453, $END=3922, and I will do a bunch of works with these variables before next line...
......