find . -type f -print
打印出来
./file1
./file2
./file3
任何让它打印的方法
file1
file2
file3
?
Find only regular files under current directory, and print them without "./
" prefix:
find -type f -printf '%P\n'
From man find, description of -printf
format:
%P File's name with the name of the command line argument under which it was found removed.
使用 sed
find . | sed "s|^\./||"
如果它们仅在当前目录中
find * -type f -print
那是你要的吗?
它可以更短
find * -type f
Another way of stripping the ./
is by using cut
like:
find -type f | cut -c3-
Further explanation can be found here
由于-printf
选项在 OSX 上不可用,find
这里有一个适用于 OSX 查找的命令,以防万一有人不想gnu find
使用brew
etc 安装:
find . -type f -execdir printf '%s\n' {} +
另一种剥离 ./
find * -type d -maxdepth 0