vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| what's the easiest way to just list directories? the shortest way I can do is ls -p | grep / if I do ls -d all I get is .. tree -d does it, but I'm not looking for that... (under windows it would dir /ad) I just know I'm missing it. Ray |
| |||
| Mon, 11 Feb 2008 15:06:04 +0000, ray did catÂ*: > what's the easiest way to just list directories? > > the shortest way I can do is > ls -p | grep / > > if I do > ls -d > all I get is Using lsd you should have stars in your eyes ;-) So, what about: $ ls -d * > . > > tree -d does it, but I'm not looking for that... > > (under windows it would dir /ad) > > I just know I'm missing it. |
| |||
| On Mon, 11 Feb 2008 15:06:04 +0000, ray wrote: > what's the easiest way to just list directories? > > the shortest way I can do is > ls -p | grep / > > if I do > ls -d > all I get is > . > > tree -d does it, but I'm not looking for that... > > (under windows it would dir /ad) > > I just know I'm missing it. > > Ray > Not strictly according to your criteria, but find works. $ find . -type d or $ find . -type d -maxdepth 1 -- Douglas Mayne |
| |||
| Loki Harfagr wrote: > Mon, 11 Feb 2008 15:06:04 +0000, ray did cat : > >> what's the easiest way to just list directories? >> >> the shortest way I can do is >> ls -p | grep / >> >> if I do >> ls -d >> all I get is > > Using lsd you should have stars in your eyes ;-) > So, what about: > $ ls -d * rjoyal@filebox:/tmp$ ls total 0 drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 vx/ drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 x/ -rw-r--r-- 1 rjoyal raynic 0 2008-02-11 10:28 x.x rjoyal@filebox:/tmp$ ls -d drwxrwxrwt 6 root root 184 2008-02-11 10:28 ./ rjoyal@filebox:/tmp$ ls -d * drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 vx/ drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 x/ -rw-r--r-- 1 rjoyal raynic 0 2008-02-11 10:28 x.x so, no, ls -d * doesn't work. I want this: drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 vx/ drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 x/ (the directories only.) Ray |
| |||
| Douglas Mayne wrote: > On Mon, 11 Feb 2008 15:06:04 +0000, ray wrote: > >> what's the easiest way to just list directories? >> >> the shortest way I can do is >> ls -p | grep / >> >> if I do >> ls -d >> all I get is >> . >> >> tree -d does it, but I'm not looking for that... >> >> (under windows it would dir /ad) >> >> I just know I'm missing it. >> >> Ray >> > Not strictly according to your criteria, but find works. > > $ find . -type d > > or > > $ find . -type d -maxdepth 1 > thanks. At least I don't feel so bad for missing the obvious. I guess I can alias lsd to one of the above... Ray |
| |||
| ray wrote: > what's the easiest way to just list directories? > > the shortest way I can do is > ls -p | grep / > > if I do > ls -d > all I get is > . > > tree -d does it, but I'm not looking for that... > > (under windows it would dir /ad) > > I just know I'm missing it. > > Ray Write and roll your own version of dir ;-), that would be constructed for your purpose. Just to compare FreeBSD %man ls|wc 361 2135 17299 Linux $ man ls|wc 229 882 9173 FreeBSD version of ls has a smaller number of options (actually 35), but they are more documented. Linux version of ls has 57 options, but they are less documented. FreeBSD man ls provides simple example EXAMPLES The following is how to do an ls listing sorted by size (and shows why ls does not need a separate option for this): ls -l | sort -n +4 FreeBSD is a unix philosophy, the number of possible options even for single tasks would be larger than number of atoms in universe. FreeBSD %which dir dir: Command not found. Linux $ which dir /usr/bin/dir --- Bogdan |
| |||
| On Mon, 11 Feb 2008 16:29:51 +0000, ray wrote: > Loki Harfagr wrote: >> Mon, 11 Feb 2008 15:06:04 +0000, ray did cat : >> >>> what's the easiest way to just list directories? >>> >>> the shortest way I can do is >>> ls -p | grep / >>> >>> if I do >>> ls -d >>> all I get is >> >> Using lsd you should have stars in your eyes ;-) So, what about: >> $ ls -d * > > rjoyal@filebox:/tmp$ ls > total 0 > drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 vx/ drwxr-xr-x 2 rjoyal > raynic 48 2008-01-23 23:23 x/ -rw-r--r-- 1 rjoyal raynic 0 2008-02-11 > 10:28 x.x > > rjoyal@filebox:/tmp$ ls -d > drwxrwxrwt 6 root root 184 2008-02-11 10:28 ./ > > rjoyal@filebox:/tmp$ ls -d * > drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 vx/ drwxr-xr-x 2 rjoyal > raynic 48 2008-01-23 23:23 x/ -rw-r--r-- 1 rjoyal raynic 0 2008-02-11 > 10:28 x.x > > so, no, ls -d * doesn't work. > > I want this: > drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 vx/ > drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 x/ > (the directories only.) > > Ray OK! I read and replied too fast :-) Then, would that one be alright?: $ ls -d */ and the usual extensions will fit: $ ls -ld */ $ ls -lad */ If I bench it that seems fine (apart the cosmetics on // but don't worry about that as one is all and all is one): ----------- $ cd /dev/shm/ && mkdir a bb ccc && touch A BB CC a/inA bb/inBB $ ls -d */ a// bb// ccc// qemu// $ ls -ld */ drwxr-xr-x 2 loki users 60 2008-02-11 19:15 a// drwxr-xr-x 2 loki users 60 2008-02-11 19:15 bb// drwxr-xr-x 2 loki users 40 2008-02-11 19:15 ccc// drwxrwx--- 2 root vmvare 40 2008-02-11 18:40 qemu// ----------- |
| |||
| On Feb 11, 8:20 pm, loki harfagr <l...@theDarkDesign.free.fr> wrote: > OK! I read and replied too fast :-) > Then, would that one be alright?: > $ ls -d */ > > and the usual extensions will fit: > $ ls -ld */ > $ ls -lad */ > > If I bench it that seems fine (apart the cosmetics on // but > don't worry about that as one is all and all is one): > ----------- > $ cd /dev/shm/ && mkdir a bb ccc && touch A BB CC a/inA bb/inBB > > $ ls -d */ > a// bb// ccc// qemu// > > $ ls -ld */ > drwxr-xr-x 2 loki users 60 2008-02-11 19:15 a// > drwxr-xr-x 2 loki users 60 2008-02-11 19:15 bb// > drwxr-xr-x 2 loki users 40 2008-02-11 19:15 ccc// > drwxrwx--- 2 root vmvare 40 2008-02-11 18:40 qemu// > ----------- probably the most simple is echo */ or echo .*/ */ but they all rely on mechanics of shell expansion in tcsh ls -d */ is expanded into a list of directories with extra / but bash ls -d */ produces only single slash. To me, original lsd version by Ray ls -p | grep / is the most accurate, and is shell independent. --- Bogdan |
| |||
| On Feb 11, 8:40 pm, B.Yanchit...@gmail.com wrote: > > in tcsh ls -d */ is expanded into a list of directories with extra / > but bash ls -d */ produces only single slash. > correction, // shit comes from aliased version of ls, not shell. alias ls ls /bin/ls $LS_OPTIONS --- Bogdan |
| ||||
| loki harfagr wrote: > On Mon, 11 Feb 2008 16:29:51 +0000, ray wrote: > >> Loki Harfagr wrote: >>> Mon, 11 Feb 2008 15:06:04 +0000, ray did cat : >>> >>>> what's the easiest way to just list directories? >>>> >>>> the shortest way I can do is >>>> ls -p | grep / >>>> >>>> if I do >>>> ls -d >>>> all I get is >>> Using lsd you should have stars in your eyes ;-) So, what about: >>> $ ls -d * >> rjoyal@filebox:/tmp$ ls >> total 0 >> drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 vx/ drwxr-xr-x 2 rjoyal >> raynic 48 2008-01-23 23:23 x/ -rw-r--r-- 1 rjoyal raynic 0 2008-02-11 >> 10:28 x.x >> >> rjoyal@filebox:/tmp$ ls -d >> drwxrwxrwt 6 root root 184 2008-02-11 10:28 ./ >> >> rjoyal@filebox:/tmp$ ls -d * >> drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 vx/ drwxr-xr-x 2 rjoyal >> raynic 48 2008-01-23 23:23 x/ -rw-r--r-- 1 rjoyal raynic 0 2008-02-11 >> 10:28 x.x >> >> so, no, ls -d * doesn't work. >> >> I want this: >> drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 vx/ >> drwxr-xr-x 2 rjoyal raynic 48 2008-01-23 23:23 x/ >> (the directories only.) >> >> Ray > > OK! I read and replied too fast :-) > Then, would that one be alright?: > $ ls -d */ > > and the usual extensions will fit: > $ ls -ld */ > $ ls -lad */ > Hey, that works! the double // appears to be a "bug" by using colors or long format because if I do /bin/ls -ld */ I don't get the double //. Thanks! I thought the -d was what I needed but couldn't get it to work... never thought of using the /. Ray |