HelpDeskLive Home
google
Your Ad Here
google
HelpDeskLive
User zone
Forum
How Was Done
How To
Download
News
Blog
Helper zone
Under Construction
Advertise
Blog  / Understanding More, Less and Touch
Added @ 2008-08-16 05:26:56
By RoboBlog

More or Less

The "more" command is designed to allow you to view the results of a command, the contents of a file, or any text type output that is given to stdout on the command line.  For example, let's say you're wanting to read the contents of a file and you type "cat file.txt".  Without the "more" command to help you out, the entire file will scroll by and all you'll get to sit and view is the end of the file as the rest will have scrolled past you.  This is where the "more" command comes in.  Here's an example of how it would be used.

cat file.txt | more

Notice the vertical bar, or "pipe" as it's called, after the initial command?   That tells the shell to forward the results of the command to whatever program you put on the command line.  I'll explain it more in another tutorial, but it is very useful.  Now, once "more" has the data output by the cat command, it then displays it in a scrollable output that you can move up and down through.  There's just one thing to be aware of.  Once you hit the end of a file with "more", it will automatically exit your viewing of the file.  You can use space to page down through the file quickly, up and down arrows to scroll slowly, and escape to get out of it entirely.

The Less command is identical to More and is used exactly the same way.  The biggest difference between the two commands is that when using Less, if you hit the end of the file, you won't automatically be kicked out.  So it's useful when browsing a file in which you're concerned with hitting the end of the file by accident.

Touch

Touch is a command that serves a couple of useful purposes.  The first is to create an empty file without having to open a text editor.  Just do "touch filename.ext" and it'll automatically create that file with a size of zero.  You can also use touch to modify the file access and modification times.  There's no truely easy way to explain how this is done, so I recommend reading the man file thuroughly before doing this.  But the essential idea is, if a file has an incorrect access or modification time, you can adjust that.
Your Ad Here
Help | Confidentialitate | News | Advertise | About Us | Contact | Blog
© 2004-2008 CMG Development