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.
我有一个文件,如:
NBU82 ------- PBW99 ------- PBE84 ------- PBW110 APSW1474 ------- TSMTBL CTTRBAPCTRK01 WEBED0075 ------- PBW132 -------
我想删除那些空的(端口后没有任何值),即只想打印
PBW110 APSW1474 ------- TSMTBL CTTRBAPCTRK01 EBED0075
awk 会更容易:
awk -v RS="---*" -v ORS="-------" 'NF>=2' file
输出:
PBW110 APSW1474 ------- TSMTBL CTTRBAPCTRK01 WEBED0075 -------
这是一个可能的sed命令,它生成与 Kent 相同的输出:
sed
sed ':a;N;/-$/!ba;/^[[:alnum:]]\+\n-/d' file