gefuchs@skolem.uucp (Gill E. Fuchs) (05/08/89)
what would be the command for getting a partial directory listings of only the subdirectories and symbolic-links ? directoried-to-the-max gill
lawrence@its.rpi.edu (David Lawrence) (05/08/89)
In article <1529@cmx.npac.syr.edu> gefuchs@skolem.uucp (Gill E. Fuchs) writes:
GEF> what would be the command for getting a partial directory listings
GEF> of only the subdirectories and symbolic-links ?
% ls -al | egrep '^[ld]'
It isn't the best as far as being stuck with the long format of ls,
but it does the job.
Dave
--
tale@rpitsmts.bitnet, tale%mts@itsgw.rpi.edu, tale@pawl.rpi.edu
seibel@cgl.ucsf.edu (George Seibel) (05/08/89)
In article <LAWRENCE.89May8010357@consult1.its.rpi.edu> tale@pawl.rpi.edu writes: ]In article <1529@cmx.npac.syr.edu> gefuchs@skolem.uucp (Gill E. Fuchs) writes: ]GEF> what would be the command for getting a partial directory listings ]GEF> of only the subdirectories and symbolic-links ? ] ]% ls -al | egrep '^[ld]' ] ]It isn't the best as far as being stuck with the long format of ls, ]but it does the job. try this for a nice listing of directories only. cant guarantee how portable it is, but it works on a number of bsd-ish and sysV-ish machines: % /bin/ls -d */ George Seibel, UCSF.
guy@auspex.auspex.com (Guy Harris) (05/09/89)
>what would be the command for getting a partial directory listings >of only the subdirectories and symbolic-links ? If you mean "what would be the command for listing all those files within a particular directory that are either subdirectories or symbolic links", try "ls -l | egrep '^[dl]'". If you want a recursive listing of that flavor, try "find . \( -type d -o -type l \) -print".
gandalf@csli.Stanford.EDU (Juergen Wagner) (05/10/89)
In article <1529@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu (Gill E. Fuchs) writes: >what would be the command for getting a partial directory listings >of only the subdirectories and symbolic-links ? This isn't really a deficiency of UNIX. It is more the lack of a more powerful "ls" command what is bothering you. Solutions to this exist, e.g.: ls -l `find . \( -name . -o -prune \) -a \( -type d -o -type l \) -print` or ls -l | grep "[ld]" -- Juergen Wagner gandalf@csli.stanford.edu wagner@arisia.xerox.com
jdpeek@RODAN.ACS.SYR.EDU (Jerry Peek) (05/11/89)
In article <1529@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu (Gill E. Fuchs) writes: > what would be the command for getting a partial directory listings > of only the subdirectories and symbolic-links ? I saw a few solutions that used "ls -l". How about "ls -F", which (on BSD) marks subdirectories with a trailing "/" and symlinks with a trailing "@"? ls -F | grep '[/@]$' When you feed BSD "ls" into a pipe, it doesn't print the filenames in columns; that's good for this test but it looks lousy on the screen if there are lots of filenames. A kludge for that looks like this: ls -F | grep '[/@]$' | pr -4 -l1 -t The "-4" gives 4 columns -- adjust that, depending on the filename length. --Jerry Peek; Syracuse University Academic Computing Services; Syracuse, NY jdpeek@rodan.acs.syr.edu, jdpeek@suvm.bitnet +1 315 443-3995
bph@buengc.BU.EDU (Blair P. Houghton) (05/12/89)
In article <8905110644.AA01902@rodan.acs.syr.edu> jdpeek@rodan.acs.syr.edu writes: >In article <1529@cmx.npac.syr.edu> gefuchs@logiclab.cis.syr.edu (Gill E. Fuchs) writes: >> what would be the command for getting a partial directory listings >> of only the subdirectories and symbolic-links ? > >When you feed BSD "ls" into a pipe, it doesn't print the filenames in >columns; Not to the real point, but if you invoke it as "ls -C" it will force the columnar output even if it's not to a tty. --Blair "My fave: ls -RFC I never: ls -RFTM"
guy@auspex.auspex.com (Guy Harris) (05/12/89)
>How about "ls -F", which (on BSD) marks subdirectories with a trailing >"/" and symlinks with a trailing "@"? It does the former on S5 as well, although since vanilla S5 doesn't have symlinks (unless they've snuck it into 3.2), it doesn't do the latter. I hope anybody whose S5 *does* have them added it to "ls" that way; SunOS's S5 "ls" ("/usr/5bin/ls") does that, and I expect S5R4's to do so as well.
morrell@hpsal2.HP.COM (Michael Morrell) (05/13/89)
/ hpsal2:comp.unix.questions / jdpeek@RODAN.ACS.SYR.EDU (Jerry Peek) / 12:44 am May 11, 1989 / When you feed BSD "ls" into a pipe, it doesn't print the filenames in columns; that's good for this test but it looks lousy on the screen if there are lots of filenames. A kludge for that looks like this: ls -F | grep '[/@]$' | pr -4 -l1 -t ---------- You can also force multicolumn output using the "-C" option to "ls". Thus, "ls -CF | grep '[/@]$'" will work. Michael
ado@elsie.UUCP (Arthur David Olson) (05/14/89)
> what would be the command for getting a partial directory listings > of only the subdirectories and symbolic-links ? Subdirectories come cheap: ls -d */. (which avoids the loss of columnar output on BSD-style systems). -- Space throughout history: Canada, 0 tries. Arthur David Olson ado@ncifcrf.gov ADO is a trademark of Ampex.
merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) (05/16/89)
In article <14660011@hpsal2.HP.COM>, morrell@hpsal2 (Michael Morrell) writes: | You can also force multicolumn output using the "-C" option to "ls". | Thus, "ls -CF | grep '[/@]$'" will work. Well, only if a directory or symbolic link shows up as the *last* file in a line. The other solution I saw, with ls -F | grep '[/@]$' | pr -5 -l1 -t is probably the only way to do it in one line with existing tools. (You need to adjust the "5" by trial-and-error.) Another bizarre solution is: ls -CFd `find . '(' -type d -o -type l ')' -print` which produces roughly the same list, if you don't mind getting subdirectories as well. And, I dislike having to 'ls' a file that 'find' already saw, but that's life. Just a UN*X Hacker, -- ***** PLEASE IGNORE THE ADDRESS IN THE HEADER ***** /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095===\ { <merlyn@agora.hf.intel.com> ...!uunet!agora.hf.intel.com!merlyn } \=Cute quote: "Welcome to Oregon... home of the California Raisins!"=/
rbj@dsys.icst.nbs.gov (Root Boy Jim) (05/16/89)
? From: Guy Harris <guy@auspex.auspex.com> ? >How about "ls -F", which (on BSD) marks subdirectories with a trailing ? >"/" and symlinks with a trailing "@"? Yeah, but what about symbolic links to directorys? They also come out with trailing `/'s. Better would be trailing `\'s, to distinguish them. BTW, Sun's `ls -lR' works dirrerently than 4.3 BSD. One follows symbolic links and the other does not. Why the change? My example above may be wrong. Perhaps it is the behaviour of `ls -R' that exhibits different behaviour. In any case, something changed. Root Boy Jim is what I am Are you what you are or what?