I get results like below from a pipeline in linux:
1 test1
1 test2
2 test3
1 test4
3 test5
1 test6
1 test7
How can I use grep to retrieve only the lines where the first column is > 1?
I get results like below from a pipeline in linux:
1 test1
1 test2
2 test3
1 test4
3 test5
1 test6
1 test7
How can I use grep to retrieve only the lines where the first column is > 1?
use the "^" char, it marks the beginning of a line
-v will not include lines starting with 1
include the extra space, so it will exclude lines like "1 asd" but not "12 asd"
grep -v "^1 "
Don't use grep
for this. Try awk
instead:
<pipeline> | awk '$1>1 {print $0}'
grep -v "^1"
EDIT: As pointed out in the comments, this solution does not filter out lines starting with multi-digit numbers. Adding a space after the 1 solves the problem:
grep -v "^1 "