find 和grep的区别
程序员文章站
2023-11-14 13:28:28
find(以文件属性为查找条件)grep(以文件内容为查找条件)grep works /usr/local/apache/htdocs/index.html 1.将/etc/passwd,有出现 root 的行取出来 # grep root /etc/passwd root:x:0:0:root:/ ......
find(以文件属性为查找条件)
grep(以文件内容为查找条件)
grep works /usr/local/apache/htdocs/index.html
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