当前位置: 移动技术网 > 科技>操作系统>Linux > find 和grep的区别

find 和grep的区别

2019年08月22日  | 移动技术网科技  | 我要评论

find(以文件属性为查找条件)

grep(以文件内容为查找条件)

grep works /usr/local/apache/htdocs/

 

1.将/etc/passwd,有出现 root 的行取出来
# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
 
 
2.将/etc/passwd,有出现 root 的行取出来,同时显示这些行在/etc/passwd的行号
# grep -n root /etc/passwd
1:root:x:0:0:root:/root:/bin/bash
30:operator:x:11:0:operator:/root:/sbin/nologin

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网