Linux Forums - Linux Help,Advice & support community:LinuxSolved.com
Linux in General => Linux Development & Programming => Topic started by: sridip on May 01, 2005, 05:39:29 PM
-
I want to get the directory listing only (i.e. listing excluding files) using linux command but i don't want to use grep. is it possible ? if yes, how ?
-
Show only directories
ls -l | grep "^d"
-
but i don't want to use grep . Is it possible or not ?
-
Hi Dear
I think its not possible without grep...
May be other knows well
Enjoy
Gaurav
-
It's possible my friend, u can do it using UNIX/LINUX shell scripting language.
However, i saw ur post and didn't reply as i see u might be expecting to list something which is for viewing only.
-
but i don't want to use grep . Is it possible or not ?
Yes, it is possible. Just use find instead of ls.
find /directoryname -type d
will find all directories in the "directoryname" "-type d" means show directories only.
Hope this helps!
-
dear
the command u said is ok,but suppose u have directories in /root as:
gaurav ajay
& suppose u have again sub-dir in gaurav as g1 & g2
the it will show the o/p like this
/root/gaurav/g1
/root/gaurav/g2
but if i only wanna gaurav then what is the solution??
Gaurav
-
dear
the command u said is ok,but suppose u have directories in /root as:
gaurav ajay
& suppose u have again sub-dir in gaurav as g1 & g2
the it will show the o/p like this
/root/gaurav/g1
/root/gaurav/g2
but if i only wanna gaurav then what is the solution??
Gaurav
Try: find /root -type d -maxdepth 1
-
Thxx dear,it works