[comp.unix.questions] Re^2: type discriminating directory listing

maart@cs.vu.nl (Maarten Litmaath) (05/12/89)

jdpeek@RODAN.ACS.SYR.EDU (Jerry Peek) writes:
\...
\	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

ls -CF | grep ...
-- 
 "`Goto considered harmful' considered |Maarten Litmaath @ VU Amsterdam:
      harmful" considered harmful!     |maart@cs.vu.nl, mcvax!botter!maart

tale@pawl.rpi.edu (David C Lawrence) (05/12/89)

jdpeek@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@star.cs.vu.nl> maart@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@pawl.rpi.edu" "tale@itsgw.rpi.edu" "tale@rpitsmts.bitnet"))
 (error "UUCP not spoken here.  Long bang paths unlikely to get mail replies.")