我有这个文件
Feb 12 13:09:36 os sshd[11320]: [ID 800047 auth.info] reprocess config line 148: ignoring RSAAuthentication option value. SSHv1 protocol is no longer supported in the server, please remove the option.
Feb 12 13:09:36 os sshd[11320]: [ID 800047 auth.info] Accepted publickey for root from 2001:778:200:4280::38 port 59677 ssh2
Feb 12 13:09:36 os sshd[11320]: [ID 800047 auth.info] Received disconnect from 2001:778:200:4280::38: 11: disconnected by user
Feb 12 13:09:38 os sshd[11196]: [ID 800047 auth.info] Keyboard-interactive (PAM) userauth failed[9] while authenticating: Authentication failed
我希望在"来自"之后获得IP地址。所以我的结果应该是:
2001:778:200:4280::38
2001:778:200:4280::38 11
是否可以在shell脚本中执行?
我尝试使用awk:
awk -F: '{print $3}' filename
但我没有得到预期的结果。
答案 0 :(得分:1)
我希望这会有所帮助,试试这个,
sed -nr 's/.*from ([^a-z]*) .*/\1/p' file_name