SUSE LINUX Documentation - Index of
SUSE LINUX Documentation - Index of
SUSE LINUX Documentation - Index of
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
100 Start-Up<br />
Viewing Files with Less and More<br />
Linux includes two small programs for viewing text files directly in the shell: less<br />
and more. Rather than starting an editor to read a file like Readme.txt, simply enter<br />
less Readme.txt to display the text in the console window. Use Space to scroll<br />
down one page. Use Page ↑ and Page ↓ to move forward or backward in the text. To<br />
exit less, press Q .<br />
Instead <strong>of</strong> less, you can also use the older program more. However, it is less convenient<br />
because it does not allow you to scroll backwards.<br />
The program less got its name from the the precept that less is more and can also be<br />
used to view the output <strong>of</strong> commands in a convenient way. To see how this works, read<br />
Section “Redirection and Pipes” (page 100).<br />
Redirection and Pipes<br />
Normally, the standard output in the shell is your screen or the console window and<br />
the standard input is the keyboard. However, the shell provides functions by which you<br />
can redirect the input or the output to another object, such as a file or another command.<br />
With the help <strong>of</strong> the symbols > and file.txt. This creates a file named file.txt that contains<br />
the list <strong>of</strong> contents <strong>of</strong> your current directory as generated by the ls command. However,<br />
if a file named file.txt already exists, this command overwrites the existing file.<br />
To prevent this, use >>. Entering ls -l >> file.txt simply appends the output<br />
<strong>of</strong> the ls command to an already existing file named file.txt. If the file does not<br />
exist, it is created.<br />
Sometimes it is also useful to use a file as the input for a command. For example, with<br />
the tr command, you can replace characters redirected from a file and write the result<br />
to the standard output, your screen. Suppose you want to replace all characters t <strong>of</strong><br />
your file.txt from the example above with x and print this to your screen. Do so<br />
by entering tr t x < file.txt.<br />
Just like the standard output, the standard error output is sent to the console. To redirect<br />
the standard error output to a file named errors, append 2> errors to the corre-