1

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

实际输出

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
4

1 回答 1

2

Don't specify . as the search directory.

find * -exec echo {} \;

The -name '*' part of your command does not eliminate names starting with a . but the globbing does. If it's a problem, then add .[!.]* before the -exec (that skips . and .., but also ..hidden; you decide whether that matters).

于 2013-06-06T13:58:05.753 回答