Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 UNIX,想知道是否可以使用 grep 或 awk 或其他东西来执行以下操作:
如果你有一个文件:
Delete-me 1 2 3 4 Delete-me 1 2 3 4 Delete-me 1 2 3 4
我怎样才能得到这个输出:
3 4 3 4 3 4
$ awk '/Delete-me/{c=3} c&&c--{next} 1' file 3 4 3 4 3 4
单程:
awk '/Delete-me/ {getline;getline;getline;print;getline;print}' 3 4 3 4 3 4
另一种方式
awk 'NR%5==0 || NR%5==4' 3 4 3 4 3 4