sed/awk:从文本流中提取模式
2011-07-01 ... /home/todd/logs/server_log_1.log ...
2011-07-02 ... /home/todd/logs/server_log_2.log ...
2011-07-03 ... /home/todd/logs/server_log_3.log ...
我有一个类似于上面的文件。我想从中提取文件名并输出到 STDOUT:
server_log_1.log
server_log_2.log
server_log_3.log
有人可以帮忙吗?谢谢!
文件名模式为 server_log_xxx.log,并且在一行中仅出现一次。
2011-07-01 ... /home/todd/logs/server_log_1.log ...
2011-07-02 ... /home/todd/logs/server_log_2.log ...
2011-07-03 ... /home/todd/logs/server_log_3.log ...
I have a file looks like the above. I want to extract the file names from it and output to STDOUT as:
server_log_1.log
server_log_2.log
server_log_3.log
Could someone help? Thanks!
The file name pattern is server_log_xxx.log, and it only occurs once in a line.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
假设“xxx”占位符只是数字:
Assuming the "xxx" placeholder is only digits:
通过以下命令管道您的文件:
Pipe your file through following command:
使用 awk 和您的输入模式:
在此处查看其操作:https://ideone.com/kcadh
HTH
With awk and your input pattern:
See it action here: https://ideone.com/kcadh
HTH