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

Title: how to get the directory listing only
Post 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 ?
Title: how to get the directory listing only
Post by: anil_garg5 on May 03, 2005, 06:09:19 AM
Show only directories
ls -l | grep "^d"
Title: how to get the directory listing only
Post by: sridip on May 04, 2005, 11:49:54 AM
but i don't want to use grep . Is it possible or not ?
Title: how to get the directory listing only
Post by: gauravbajaj on May 04, 2005, 12:42:13 PM
Hi Dear
I think its not possible without grep...
May be other knows well

Enjoy
Gaurav
Title: how to get the directory listing only
Post by: dragoncity99 on May 04, 2005, 01:14:34 PM
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.
Title: how to get the directory listing only
Post by: unixadmin on June 15, 2005, 03:58:23 AM
Quote from: "sridip"
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!
Title: how to get the directory listing only
Post by: gauravbajaj on June 15, 2005, 08:42:36 AM
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
Title: how to get the directory listing only
Post by: unixadmin on June 16, 2005, 01:01:13 AM
Quote from: "gauravbajaj"
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
Title: how to get the directory listing only
Post by: gauravbajaj on June 16, 2005, 03:37:12 AM
Thxx dear,it works