2012-12-05 47 views

回答

6

使用find找到只在当前目录中的文件或一个目录下:

$ find . -maxdepth 2 -type f 

演示:

# Show whole directory structure, digits are files, letters are folders. 
$ find . 
. 
./1 
./2 
./3 
./4 
./A 
./A/11 
./B 
./B/22 
./C 
./C/33 
./D 
./D/44 
./D/E 
./D/F 
./D/F/444 
./D/F/G 
./D/F/G/4444 

# Find only files at a maximum depth of 2 
$ find . -maxdepth 2 -type f 
./1 
./2 
./3 
./4 
./A/11 
./B/22 
./C/33 
./D/44 
1

您可以发现这样做:

find . -maxdepth 2 
+0

这个超匹配,它发现目录以及文件。 –

2

这其中列出了一切在当前工作目录中的目录中:ls -l */

两个命令的组合将包括在当前目录中的文件,以及:ls -l */; ls -l