Ok I have the following situation.
好的,我有以下情况。
Caps are directories, lowercase are files.
大写是目录,小写是文件。
A/aa
B/bb
C/cc
D/dd
D/E/ddd
D/F/G/dddd
a
b
c
d
I want to do a ls that lists
我想做一个列出来的ls
a
b
c
d
A/aa
B/bb
C/cc
D/dd
but not either
但不
D/E/ddd
D/F/G/dddd
3 个解决方案
#1
6
Using find
to find only files in the current directory or one directory down:
使用find只查找当前目录中的文件或一个目录下的文件:
$ find . -maxdepth 2 -type f
Demo:
演示:
# 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
#2
2
This one lists everything inside directories in your current working dir: ls -l */
这个列表列出了当前工作目录中的所有目录:ls -l */。
A combination of two commands will include files in your current directory as well: ls -l */; ls -l
两个命令的组合将包括当前目录中的文件:ls -l */;ls - l
#3
1
You can do this with find:
你可以使用find:
find . -maxdepth 2
#1
6
Using find
to find only files in the current directory or one directory down:
使用find只查找当前目录中的文件或一个目录下的文件:
$ find . -maxdepth 2 -type f
Demo:
演示:
# 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
#2
2
This one lists everything inside directories in your current working dir: ls -l */
这个列表列出了当前工作目录中的所有目录:ls -l */。
A combination of two commands will include files in your current directory as well: ls -l */; ls -l
两个命令的组合将包括当前目录中的文件:ls -l */;ls - l
#3
1
You can do this with find:
你可以使用find:
find . -maxdepth 2