Hi,
I want to delete rows that have 0 at column 4.
The file looks like this:
chr01 13 61 2
chr01 65 153 0
chr01 157 309 1
chr01 313 309 0
chr01 317 469 1
chr01 473 557 0
I want to delete all rows with a 0 at column 4
chr01 13 61 2
chr01 157 309 1
chr01 317 469 1
Thanks
try this
awk -F " " '{ if ( $4 != 0 ) print $0 }' infile
@balajesuri yours is much trimmed
Few points to observe:
- awk already separates the fields based on whitespaces. So,
-F " "
is really not necessary.
- awk follows this:
condition {action}
by default. So an if-statement can be masked as condition{action}
, unless its use is inevitable.
- awk prints the current line by default. So
print $0
is redundant.
- Implementing all the above points you get what is in post #2 above
Well, to shorten it even more, we can say:
awk '$4' inputfile
1 Like