On Thu, 17 Feb 2005 16:25:04 +1300
rob wrote:

> Wesley,
> No I couldn't get type <filename> less to work either.

"type" on linux is not the same as "type" on dos. man type shows its a
completely different beast, in fact i don't really comprehend what it
does do.

I don't know
> about the vertical character in your syntax, I've never understood that.

The vertical symbol | is called pipe. Think of it as a plumber would, it takes 
the output of one command and pipes it to the next command. hence:

cat longfile

sends longfile to the terminal, like type in DOS.

'less' pages output - displays it's input page by page.

cat longfile | less 

sends the output of 'cat longfile' to the input of 'less', ie it effectively 
pages longfile on the screen.

you can get the same effect with 

less longfile, but don't let that fool you, piping is important on the
command line, it lets you do a lot, viz:

grep "pub.pdf" /var/log/apache/access.log |cut -d" " -f1 | sort | uniq |
wc -l  

(thats all one line)

this searches (grep)  my apache log files for entries showing someone
downloaded the file pub.pdf, then cuts the first field (the ip address),
sorts it, deletes recurring entries (uniq) and counts the number of
lines (wc-l), then displays the output. It tells me how many unique ip
addresses have downloaded the file pub.pdf from my webserver, therefore
a (very bad)estimate of the number of people who might turn up on Friday
night. Real World problems can be solved in a similar manner.

-- 
Nick Rout
Barrister & Solicitor
Christchurch
<http://www.rout.co.nz>
<[EMAIL PROTECTED]>

Reply via email to