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

Re: quick howto-command questions?



On Wed, Mar 21, 2001 at 07:10:03PM -0800, Alexander Poquet wrote:
> > 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.
> 


ls |column -c80 |less
will pipe ls thru column, make it 80 wide, and then through less.


> 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.


easy, simply add the -x flag to column, it

ls |column -x -c80 |less



-- 
Jim Richardson
	Anarchist, pagan and proud of it
WWW.eskimo.com/~warlock
	Linux, because life's too short for a buggy OS.



Reply to: