if condition

if

chr1:109457160 1 109457160 99.1735537190083 +
chr1:109457233 1 109457233 99.1735537190083 -
chr1:109457614 1 109457614 99.1735537190083 +
chr1:109457618 1 109457618 100 +
chr1:109457943 1 109457943 100 -
chr1:109458224 1 109458224 99.1735537190083 -

file1.txt

If 6th column in file1.txt is -, i want to grab all the rows and print them and save it as a minus. txt

the output will be

chr1:109457233 1 109457233 99.1735537190083 -
chr1:109457943 1 109457943 100 -
chr1:109458224 1 109458224 99.1735537190083 -

Maybe it's not this simple, but, couldn't you just grep it out?

grep - file1.txt >> minus.txt
1 Like

If you only want to catch '-' in field 6, you'll want this:

awk -F'[ :]' '$6=="-"' file1.txt
1 Like

Is the minus always the last character on a line?

grep '\-$' x.dat >> minus.txt
1 Like