How to display file only in bash?
My last article was to display folder only using “ls” command, this time I want to share how to display files only in bash.
Step 1:
For this it is easy to use “find” command which is pre-installed in most of the Linux distro available in the market.
Here is the command snippet:
:/> find . -maxdepth 1 -type f
using -maxdepth 1 ensure that your search remains only in the current directory (if you don’t want then just remove “.” from the snippet).
Step 2:
Using ls and grep or egrep.
:/> ls -l | grep -v ‘^d’
:/> ls -l | egrep -v ‘^d’