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
a
b
c
d
A/aa
B/bb
C/cc
D/dd
but not either
D/E/ddd
D/F/G/dddd
Using find
to find only files in the current directory or one directory down:
$ 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
This one lists everything inside directories in your current working dir: ls -l */
A combination of two commands will include files in your current directory as well: ls -l */; ls -l
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With