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.
如何从以下文本中删除所有内容Part1,Part2包括Part1和,?Part2
Part1
Part2
ABC Part1 text more text Part2 DEF
结果应该是:
ABC DEF
使用打印标志awk:
awk
$ awk '/Part1/{p=1}!p;/Part2/{p=0}' file ABC DEF
尝试这个 :
awk '/^Part1/,/^Part2/{next}{print}' file
使用 sed:
sed '/Part1/,/Part2/d' filename