![](/img/trans.png)
[英]Remove only Alphabetic Character lines in a linux file by using Sed/Awk
[英]remove a word and its following line in linux using sed or awk
我想知道如何刪除以* dd
開頭的單詞並保留其當前行,但刪除以下行。
我使用此命令刪除了sed "s/^\\*.dd//" test.cbl > test.cbl.new
它顯示得很好,但我無法刪除下一行。
使用以下sed
解決方案:
sed '/^\*.dd/{s/^\*.dd//;n;d};' test.cbl > test.cbl.new
將搜索您的模式,然后搜索並替換模式( s///
),然后刪除下一行( n;d
)。
perl -pe 'if (s/^\* dd//) { readline }' test.cbl
應該這樣做。 或更壓縮:
perl -pe '<> if s/^\* dd/' test.cbl
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.