[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: quick howto-command questions?



> ls -a | grep ".c$"

This is silly, of course, but if you want to be rigorous about it you
probably should do 'ls -a | grep "\\.c$"' because grep (unlike the shell)
uses proper regex syntax -- in which '.' is a special character (match any
char).  Thus 'ls -a | grep ".c$" would list files such as 'fooc', so
escaping the . is necessary.  Two backslashes are required to get
through the shell escaping.

Apropos, I have a question: frequently I am in a directory (such as /dev,
for example) which has more stuff in it than I can see in one screenful.
Normally I pipe it through less, but am bothered by the 'one file per
line'-isms that ls spits out in this case.  I understand the necessity
of this behaviour, but I was wondering, is there some option which
forces columnated output regardless of the presence of a filter?  -C
is documented as column-formatting, but it is ignored in a pipe.

In a related question, can one force sort by rows instead of by
columns, ie, "a b c\nd e f" instead of "a c e\nb d f"?  I say related
because when viewing copious output through a pager, it would be
useful to have sort by rows instead of by columns, which is the default
behaviour.

-- 
Alexander Poquet                | We leave the obvious generalizations to the
atpoquet@ucdavis.edu            | reader.                  -- Israel Herstein
Use of PGP preferable in reply  |               Use Linux!

Attachment: pgpoFiZ5Hcec_.pgp
Description: PGP signature


Reply to: