Re^2: type discriminating directory listing
David C Lawrence
tale at pawl.rpi.edu
Sat May 13 02:28:56 AEST 1989
jdpeek at RODAN.ACS.SYR.EDU (Jerry Peek) writes:
\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
In article <2508 at star.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
ML> ls -CF | grep ...
This is the second posting that said "so use ls -C".
I'm sure if you look at this you will see quite readily that the
second pipeline does not do the first except in rare, coincidental
circumstancs. grep acts on line-at-a-time. If you use the first
regexp, then you will get only those lines which have / or @ trailing
them and then you get the entire line to boot! Taking out the $
leaves you with finding any line with an @ or / anywhere in the line,
whether they are a valid part of the file/pathname or not, and still
prints the whole line when it finds matches.
If you want columnar output from a grep on filenames and you want it
to list only those file names which matched, you really must do it
yourself after the grep is finished. (Or attack the problem from a
different angle with awk, sed or perl.)
Dave
--
(setq mail '("tale at pawl.rpi.edu" "tale at itsgw.rpi.edu" "tale at rpitsmts.bitnet"))
(error "UUCP not spoken here. Long bang paths unlikely to get mail replies.")
More information about the Comp.unix.questions
mailing list