Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove lines containing a number less than/greater than a limit?

Tags:

grep

sed

pipe

I have a lot of lines like this, produced by grep -n:

path/to/dir/file1.txt:4: Match
path/to/dir/file1.txt:40: Another Match
path/to/dir/file2.txt:2: Match
path/to/dir/file2.txt:564: Yet another Match

I'd like to eliminate lines where the line number is less than (say) 10. I know I can get the line number easily with cut -d: -f2, but how could you then use this to discard the lines and continue piping the rest of the output in full so you end up with:

path/to/dir/file1.txt:40: Another Match
path/to/dir/file2.txt:564: Yet another Match
like image 855
Inductiveload Avatar asked Nov 25 '25 00:11

Inductiveload


1 Answers

You can do:

your command | awk -F: '$2>=10'
like image 144
jaypal singh Avatar answered Nov 28 '25 16:11

jaypal singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!