[英]Find a word in a file and print it in bash
I have a file in /home/{user}/client.log
.我在
/home/{user}/client.log
有一个文件。
clinet.log
contains a work lcid
. clinet.log
包含一个工作lcid
。
How can I find a word lcid
in a file client.log
and print it using bash.如何在文件
client.log
找到单词lcid
并使用 bash 打印它。
use the following command: grep "lcid" . -R
使用以下命令:
grep "lcid" . -R
grep "lcid" . -R
Okay, with the additional information you provided this will do the trick for you:好的,使用您提供的其他信息,这将为您解决问题:
sed -n "s/.*lcid.:.\(\w*\)./\1/p" client.log
Let me know if this helps.如果这有帮助,请告诉我。
Thanks all.谢谢大家。 I got this working by using the following command
我通过使用以下命令得到了这个工作
grep 'lcid' client.log | grep 'lcid' client.log | cut -d'"' -f4
剪切 -d'"' -f4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.