I discovered that
ls -AF /var/ |grep \/$
helps me to find all directories from a directories without more information. Now i need exactly the opposite - showing all files without any further information just the file name in each line
file1
file2
file3
and filtering the directories because those - i don't need
Simplest way: its not L its digit - 1
$ ls -1
For finding files matching a certain expression there exists find
. Its man-page is quite good and includes also some interesting examples. For getting only the files of a directory you can use:
find /var -maxdepth 1 -type f -printf "%f\n"
Just use the -v
switch for grep
to invert the match:
ls -AF /var/ |grep -v /$
ls -1Ap /var/ | grep -v /
Similar to @choroba's answer, but this version will list clean file names on each line without appending additional classification indicators, if you don't want them.
-p flag appends / to directories
-1 flag is always handy to list one file per line
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