[wellylug] cat README | more ???

michael at diaspora.gen.nz michael at diaspora.gen.nz
Wed Nov 3 13:28:13 NZDT 2004


>The blatantly obvious difference between "more" and "less" is that (by 
>default) "more" leaves the text in your terminal, while "less" takes over the 
>terminal then cleans up the text when you're finished.  So if I want the text 
>I've viewed to remain on the screen (for example, so I can copy and paste 
>from it) I use more; and if I want it to go away (for example, so I can see 
>the commands I previously typed) I use less, or emacs.

'more' can't go backwards through pipes (at least traditionally).

So if you have:

    long-complicated-command | more

And you press the 'b' key in more, nothing will happen.  If you'd use
less, then you'd be in luck.  I believe less is also more full featured
in regards to searching backwards and forwards.

Actually, the behaviour of 'less' in sending the terminal init and
deinit strings on exit and entry drives me nuts; I always have this in
my .profiles:

    LESS="-smeX"

The -X flag is what disables sending the init strings.

And as to using 'cat', cat is 'conCATenate'; you should only use it when
multiple files are required.  (In theory; I use it unnecessarily myself.)

For example, the following:

    cat bigfile | grep ... | grep -v ...

Could readily be replaced with:

    < bigfile grep ... | grep -v ...

Google for 'randal schwartz Useless Use of Cat Award' if you want to
know more.
    -- michael.




More information about the wellylug mailing list