|
发表于 2005-6-28 23:46:07
|
显示全部楼层
Post by providence
find . -name "*.txt" -print与find . -name *.txt -print
前一个会授索子目录,后一个不会,哪位明白说一下原因!
传给find的模式应该用""括起来
我的系统centos4.1 ,bash-3.0-19.2
- [xxxx]$ find . -name *.html -print
- ./build/comps.html
- ./build/howto.html
- ./build/RedHat-CD-HOWTO_files/note.html
- ./build/RedHat-CD-HOWTO.html
- [xxxx]$ find . -name "*.html" -print
- ./build/comps.html
- ./build/howto.html
- ./build/RedHat-CD-HOWTO_files/note.html
- ./build/RedHat-CD-HOWTO.html
复制代码
如果进到build目录,则
- [xxxx]$ cd build
- [xxxx]$ find . -name "*.html" -print
- ./comps.html
- ./howto.html
- ./RedHat-CD-HOWTO_files/note.html
- ./RedHat-CD-HOWTO.html
- [xxxx]$ find . -name *.html -print
- find: paths must precede expression
- Usage: find [path...] [expression]
复制代码
find . -name ”*.html“,*.html被传给find,没有问题,
对于find . -name *.html
*.html的通配符首先被bash处理,如果当前目录没有.html文件,
那么(在我用的系统里),*.html被传给find,ok
如果当前目录有.html文件,*.html被bash 展开,再传给find
如果当前目录只有一个html文件,find可以找到这个html
如果有多个,则这种情况下find命令没有被正确调用,不执行 |
|