December 16, 2017, 06:39:21 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: how to get the directory listing only  (Read 3685 times)

Offline sridip

  • Linux Noob !
  • *
  • Posts: 9
how to get the directory listing only
« 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 ?

Offline anil_garg5

  • Linux Learner
  • ***
  • Posts: 71
how to get the directory listing only
« Reply #1 on: May 03, 2005, 06:09:19 AM »
Show only directories
ls -l | grep "^d"

Offline sridip

  • Linux Noob !
  • *
  • Posts: 9
how to get the directory listing only
« Reply #2 on: May 04, 2005, 11:49:54 AM »
but i don't want to use grep . Is it possible or not ?

Offline gauravbajaj

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 658
how to get the directory listing only
« Reply #3 on: May 04, 2005, 12:42:13 PM »
Hi Dear
I think its not possible without grep...
May be other knows well

Enjoy
Gaurav

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
how to get the directory listing only
« Reply #4 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.

Offline unixadmin

  • Linux Noob !
  • *
  • Posts: 5
how to get the directory listing only
« Reply #5 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!

Offline gauravbajaj

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 658
how to get the directory listing only
« Reply #6 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

Offline unixadmin

  • Linux Noob !
  • *
  • Posts: 5
how to get the directory listing only
« Reply #7 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

Offline gauravbajaj

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 658
how to get the directory listing only
« Reply #8 on: June 16, 2005, 03:37:12 AM »
Thxx dear,it works