Get directories names 

Newsgroups:  gmane.linux.debian.user
Date:        Tue, 09 Nov 2004 16:56:06 -0600
> I used to use the following command/alias to get the names under the
> current directory in RH:

To get a list of directories in the CURRENT directory, just do:

ls -d */

To get a list of directories WITHIN a directory, you could do:

ls -d criteria*/*/

Alex Malinovich

Get directories names 

>>I used to use the following command/alias to get the names under the
>>current directory in RH:
>>
>>ls -l <criteria> | grep ^d | cut -c57-
>>
>>but in Debian, the position of the file name is not fixed.
>
> It is for me, and the above command works perfectly.

It is?

pretzalz@Pretzalz:~/projects/test1$ mkdir subdir
pretzalz@Pretzalz:~/projects/test1$ ls -l | grep ^d | cut -c57-
pretzalz@Pretzalz:~/projects/test1$ ls -l
total 4
drwxr-xr-x  2 pretzalz pretzalz 4096 Nov  9 22:20 subdir
pretzalz@Pretzalz:~/projects/test1$ dd if=/dev/zero of=hole bs=1k count=10 seek=1M
10+0 records in
10+0 records out
10240 bytes transferred in 0.000647 seconds (15827849 bytes/sec)
pretzalz@Pretzalz:~/projects/test1$ ls -l | grep ^d | cut -c57-
subdir
pretzalz@Pretzalz:~/projects/test1$ ls -l
total 24
-rw-r--r--  1 pretzalz pretzalz 1073752064 Nov  9 22:23 hole
drwxr-xr-x  2 pretzalz pretzalz       4096 Nov  9 22:20 subdir

And I agree that find is the best solution.

Get directories names 

> >It is for me, and the above command works perfectly.
>
> It is?

Nope. Observe some partial output:

mauritsvanrees:~# ls -l
drwxr-x---  3 root root  256 2004-09-24 16:18 commands
maurits@mauritsvanrees:~$ ls -l
drwx------    3 maurits maurits  304 2004-08-30 21:13 Desktop
drwx------  118 maurits maurits 3184 2004-11-01 23:15 az
maurits@mauritsvanrees:/opt$ ls -l
-rw-r--r--  1 maurits maurits  19194716 2004-08-01 00:33 02.Gebed.wav

The position of the filename is influenced by:

  • size of the largest dir
  • lenghth of user and group name
  • size of file/dir
  • maybe some more.

So yes, `find' is much better.

Maurits van Rees