[英]I am trying to use the grep command in linux. how to grep similar words and phrases
我怎样才能 grep 文件中以特定字母(例如“n”)开头的所有行? 对于文件/var/log/messages,我试过了
# cat /var/log/messages | grep n*
它没有用
所有以n
开头的行:
cat /var/log/messages | grep "^n"
对模式使用正则表达式
^ 表示输入字符串的开始
$ 表示输入字符串的结束
cat /var/log/messages | grep ^n
看看https://www.linux.com/topic/desktop/introduction-regular-expressions-new-linux-users/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.