Display/List only folders/directories or only files in Linux/Unix
===============================================
1) Display or list all directories in current location in Linux/Unix
Type the following command:
ls -ld */
ls -l | grep '^d'
ls -l | egrep '^d'
Display or list the hidden folder at current location, type the following command:
ls -ld .*/
ls -la | grep '^d'
ls -la | egrep '^d'
This command lists directories in the current path/folder: ls -d */
*/ is a pattern that matches all of the subfolders in the current folder (* would match all files and subfolders; the / restricts it to folders/directories). for e.g. to list all subfolders under /home/yogesh/, use ls -d /home/yogesh/*/
2) Display or list all files in current location in Linux/Unix
ls -l | grep -v '^d'
ls -l | egrep -v '^d'
ls -la | egrep -v '^d'
3) List all the directories at 1 Level depth in /etc including hidden folders with find command:
find /etc -maxdepth 1 -type d
4) You Can use find command to list either files or folders/directories:
The find command can be used as follows to list all directories in /etc
find /etc -type d
find /etc -type d -ls
find . -type d -ls
5) To list/see the zombie/defunct process in Linux/Unix:
pf -ef | grep -i defunct
ps -elf | grep -w Z
6) How to create alias to save the time:
alias lf="ls -ls | egrep -v '^d'"
alias ldir="ls -l | egrep '^d'"
No comments:
Post a Comment