好的,可能是一个愚蠢的问题,但为什么这不起作用?
find . -name Orna* -ls
似乎“发现”应该能够处理这个简单的请求......我在这里错过了一些东西吗?这应该是“find”命令的基本执行,但linux是愚蠢的,或者我可能。
答案 0 :(得分:3)
您需要引用name参数,以便shell不扩展通配符,例如
find . -name "Orna*" -ls
答案 1 :(得分:3)
使用Find Command的正确方法是以下短语
find . -type f -name "filename" # this command used to find files from the curent dir
find . -type d -name "dir name" # this command used to find dirs from the curent dir
find /. -type f -name "filename" # this command used to find files from the system
find /. -type d -name "dir name" # this command used to find dirs from the system
我希望它对你有所帮助
答案 2 :(得分:1)
解释"为什么"比现有答案多一点 - 在运行被调用的命令之前,通过shell 扩展通配符。因此,我们假设您当前的目录包含文件Orna1
和Orna2
。
在这种情况下,当你运行
find . -name Orna* -ls
...... shell实际调用的是:
find . -name Orna1 Orna2 -ls
...因此,find
根本看不到通配符表达式!
引用扩展,如:
find . -name 'Orna*' -ls
...防止shell在运行命令之前尝试扩展通配符,从而防止出现此问题。