如何同时进行 grep 和 cut
同时进行抓取和切割时遇到困难 我有一个文件 test.txt
。 文件里面是这个语法
File: blah.txt Location: /home/john/Documents/play/blah.txt
File: testing.txt Location /home/john
我的命令是./delete -r (filename)
,假设文件名是blah.txt
。
我如何在 test.txt
中搜索 blah.txt
并将 /home/john/Documents/play/blah.txt
剪切出来并放入它在一个变量中
Having trouble with grepping and cutting at the same time
I have a file test.txt
.
Inside the file is this syntax
File: blah.txt Location: /home/john/Documents/play/blah.txt
File: testing.txt Location /home/john
My command is ./delete -r (filename)
, say filename is blah.txt
.
How would i search test.txt
for blah.txt
and cut the /home/john/Documents/play/blah.txt
out and put it in a variable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
总是希望在您的任务中尽可能少地涉及外部命令。
您可以使用 single awk 命令实现您想要的效果:
Prefer always to involse as less as possible external command for your task.
You can achive what you want using single awk command:
试试这个;)
Try this one ;)