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 -------
sedKent と同じ出力を生成するコマンドを次に示します。
sed
sed ':a;N;/-$/!ba;/^[[:alnum:]]\+\n-/d' file