几个“查找”命令
时间:2006-10-18 来源:richardliu1123
正则表达式 不同的“查找”命令有不同的用途。
1.locate [str1]
查找最快,它是在数据库中查找文件,能找到跟所给字符串匹配所有文件,但不是实时数据,要手工updatedb;
2.which [str1]
查找可执行文件所处的位置
[root@clone bin]# which java
/usr/java/jdk1.3.1_06/bin/java
3.whereis [str1] 查找可执行文件的位置及相关的位置 [root@clone bin]# whereis man
man: /usr/bin/man /etc/man.config /usr/local/man /usr/share/man /usr/share/man/man1/man.1.gz
4.grep (适用于正则表达式) 查找文件中与给定字符相匹配的行 [root@clone bin]# grep -n "^http.*80[^0-9]\+" /etc/services
85:http 80/tcp www www-http # WorldWideWeb HTTP
86:http 80/udp www www-http # HyperText Transfer Protocol
5.find 根据给定路径查找文件; [root@clone bin]# find / -nouser -and -empty -exec ls -l {} \;
/usr/java/jdk1.3.1_06/bin/java
3.whereis [str1] 查找可执行文件的位置及相关的位置 [root@clone bin]# whereis man
man: /usr/bin/man /etc/man.config /usr/local/man /usr/share/man /usr/share/man/man1/man.1.gz
4.grep (适用于正则表达式) 查找文件中与给定字符相匹配的行 [root@clone bin]# grep -n "^http.*80[^0-9]\+" /etc/services
85:http 80/tcp www www-http # WorldWideWeb HTTP
86:http 80/udp www www-http # HyperText Transfer Protocol
5.find 根据给定路径查找文件; [root@clone bin]# find / -nouser -and -empty -exec ls -l {} \;
相关阅读 更多 +