入力ファイルは次のようになります。
Jan 23 14:57:16 TCP 217.79.188.21:80 in
私は試した:
sed 's/:[^:]* in/ in/'
ただし、:80 を削除するのではなく、:16 を削除し続けます。
どうすればこれを修正できますか?
これはあなたのために働くかもしれません:
echo "Jan 23 14:57:16 TCP 217.79.188.21:80 in" | sed 's/:..//3'
Jan 23 14:57:16 TCP 217.79.188.21 in
または(ポート番号は任意の番号である可能性が高いため):
echo "Jan 23 14:57:16 TCP 217.79.188.21:80 in" | sed 's/:[^ ]*//2'
Jan 23 14:57:16 TCP 217.79.188.21 in
sed -E -e 's/:[[:digit:]]{1,3} in/ in/'
Try matching both the IP and the port, and replacing it with the just the IP.