type discriminating directory listing

Randal L. Schwartz @ Stonehenge merlyn at intelob.intel.com
Wed May 17 00:08:49 AEST 1989


In article <14660011 at hpsal2.HP.COM>, morrell at 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 at agora.hf.intel.com> ...!uunet!agora.hf.intel.com!merlyn    }
\=Cute quote: "Welcome to Oregon... home of the California Raisins!"=/



More information about the Comp.unix.questions mailing list