【发布时间】:2014-12-25 14:30:51
【问题描述】:
哪个命令允许从主目录开始查找特定文件(例如:test.doc)?
我需要先'su username',然后是 ls->cd 还是有特定的命令这样做?
【问题讨论】:
标签: linux shell unix command-line command
哪个命令允许从主目录开始查找特定文件(例如:test.doc)?
我需要先'su username',然后是 ls->cd 还是有特定的命令这样做?
【问题讨论】:
标签: linux shell unix command-line command
使用find 命令:
find /home/foo -name 'test.doc'
或者对于不区分大小写的搜索:
find /home/foo -iname 'test.doc'
这将输出包含相对路径的文件名。如果您想要一些更详细的信息,例如ls -l test.doc 的输出,您可以这样做:
find /home/foo -iname 'test.doc' -exec ls -lh {} \;
或者只是将它发送到xargs:
find /home/foo -iname 'test.doc' | xargs ls -lh
【讨论】:
find -ls 感到很愚蠢。谢谢。