[Nottingham] newbie Hi!

Alex Tibbles alex_tibbles at yahoo.co.uk
Fri Jan 6 18:40:30 GMT 2006


--- Graeme Fowler <graeme at graemef.net> wrote:
> Alternatively:
> 
> ls -l | less
> 
> Because "less is more". With more functionality, ie.
> you can page up, 
> page down, line up, line down, search for things,
> isolate specific 
> lines, save stuff to files... and, er, more :)
> 
> less is my pager of choice; I tend to feel a bit
> like my legs have been 
> chopped off without it.

Just be careful how big the file is - multi-gig logs
files should not be searched with less in my
experience. I think it holds all the paged data in
memory. head, tail and grep are great because you can
then take an arbitrary chunk of a file:

head -n 5 filename
gives top 5 lines

tail -n 5 filename
gives bottom 5 lines

grep -C 3 string filename
gives three lines context each way around found
instances of string. Very useful when trying to
understand a code-base:

grep -r -C 2 'some_function_name(' *
This gives all the calls (and definitions/declarations
of some function) to some_function_name (assuming you
have a coding standard where no-one puts spaces before
the parens). You can use regular expressions too as
the string(!).

Alex


		
___________________________________________________________ 
NEW Yahoo! Cars - sell your car and browse thousands of new and used cars online! http://uk.cars.yahoo.com/



More information about the Nottingham mailing list