[mdlug] UNIX tips: Learn 10 good UNIX usage habits
Raymond McLaughlin
driveray at ameritech.net
Wed Mar 12 00:06:04 EDT 2008
Aaron Kulkis wrote:
> Clinton V. Weiss wrote:
>
>> 3. I want to quickly read the contents of the file.
>>
>> Clinton =)
>
> That would be true in 1983.
> However, since then has come the invention
> of both more....and less, too!
>
> more file
> or cmd | more
>
>
> less file
> or cmd | less]
>
>
> (Less allows you to page backwards through piped input).
How ever, a pager such as less requires you to exit before you can
continue to work, and is not suitable for piping. I use both, my choice
depending on the context, expected size of out put, and ultimate intention.
For instance, if I'm working in a graphical console with a large scroll
back buffer I might just cat a file, and scroll back and forth with my
mouse, perhaps selecting parts of the text for some copy/paste
operation. Also, the "cat file | " syntax might be less direct than the
redirect syntax, but I'm inclined to use "cat file" to see the content
of a file, and then "<Up Arrow> | ..." to avoid retyping a (possibly
long) file descriptor.
Both less and cat can be useful tools. I would give some thought to
efficiency in writing a script, but at the command line I would opt for
less typing.
More information about the mdlug
mailing list