Tuesday, 10 July 2012

how to use ls commands

Sometimes we need to display only the directories in a folder. At this case use the following command
$ ls -l | egrep ‘^d’
It will display only the directory list with some options..
If you need to see only the files, use -v to get the converse effect of the above command
$ ls -l | egrep -v ‘^d’
Every time we cant execute these big commands. Better we can use alias for these commands.
let me call ldir as list directories lf as list files..
Now, we can create alias as
$ alias ldir=”ls -l | egrep ‘^d’”
and for files
$ alias lf=”ls -l | egrep -v ‘^d’”
Now open the bash profile in vi editore
$ vi .bash_profile
Append the above two alias commands save and close.
Now, check by typing
$ ldir /etc
and
$ lf /etc

0 comments:

Post a Comment

 

Subscribe to our Newsletter

Contact our Support

Email us: youremail@gmail.com

Our Team Memebers