使用exec echo选项查找命令包含./ in filename

时间:2013-06-06 12:46:39

标签: linux shell find

如何避免从输出中显示前导./

实际输出

test@testmachine:/usr/lib$ find . -name "*" -exec echo {} \;
.
./pymodules/python2.7/pyliblzma-0.5.3.egg-info
./pymodules/python2.7/pyliblzma-0.5.3.egg-info/PKG-INFO
./pymodules/python2.7/pyliblzma-0.5.3.egg-info/top_level.txt
./pymodules/python2.7/pyliblzma-0.5.3.egg-info/dependency_links.txt
./pymodules/python2.7/pyliblzma-0.5.3.egg-info/SOURCES.txt

必填项:

test@testmachine:/usr/lib$ find . -name "*" -exec xxxxxxxxxx \;

pymodules/python2.7/pyliblzma-0.5.3.egg-info
pymodules/python2.7/pyliblzma-0.5.3.egg-info/PKG-INFO
pymodules/python2.7/pyliblzma-0.5.3.egg-info/top_level.txt
pymodules/python2.7/pyliblzma-0.5.3.egg-info/dependency_links.txt
pymodules/python2.7/pyliblzma-0.5.3.egg-info/SOURCES.txt

1 个答案:

答案 0 :(得分:2)

不要将.指定为搜索目录。

find * -exec echo {} \;

命令的-name '*'部分不会删除以.开头的名称,但是通常会删除名称。如果这是一个问题,请在.[!.]*之前添加-exec(跳过...,还要..hidden;您决定是否重要)。< / p>