2
我有很多像這樣的線路,由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
我想消除行的行號小於(比如說)10.我知道我可以很容易地得到行號與cut -d: -f2
,但怎麼能這樣你就結束了,你再使用此放棄行,並繼續在管道滿輸出的其餘部分:
path/to/dir/file1.txt:40: Another Match
path/to/dir/file2.txt:564: Yet another Match
所以你認爲你的文件名或目錄名不會包含':'? – devnull
在這種情況下,這是已知的,但在一般情況下,你是對的,這將是一個問題。 – Inductiveload