26.10.2012 Views

SUSE LINUX Documentation - Index of

SUSE LINUX Documentation - Index of

SUSE LINUX Documentation - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

sponding command. Both standard output and standard error are saved to one file named<br />

alloutput if you append >& alloutput.<br />

Using pipelines or pipes is also a sort redirection, although the use <strong>of</strong> the pipe is not<br />

constrained to files. With a pipe (|), you can combine several commands, using the<br />

output <strong>of</strong> one command as input for the next command. For example, to view the contents<br />

or your current directory in less, enter ls | less. This only makes sense if the<br />

normal output with ls would be too lengthy. For instance, if you view the contents <strong>of</strong><br />

the dev directory with ls /dev, you only see a small portion in the window. View<br />

the entire list with ls /dev | less.<br />

3.1.5 Archives and Data Compression<br />

Now that you have already created a number <strong>of</strong> files and directories, consider the subject<br />

<strong>of</strong> archives and data compression. Suppose you want to have the entire test directory<br />

packed in one file that you can save on a USB stick as a backup copy or send by e-mail.<br />

To do so, use the command tar (for tape archiver). With tar --help, view all the<br />

options for the tar command. The most important <strong>of</strong> these options are explained here:<br />

-c<br />

-t<br />

-x<br />

-v<br />

-f<br />

(for create) Create a new archive.<br />

(for table) Display the contents <strong>of</strong> an archive.<br />

(for extract) Unpack the archive.<br />

(for verbose) Show all files on screen while creating the archive.<br />

(for file) Choose a filename for the archive file. When creating an archive, this<br />

option must always be given as the last one.<br />

To pack the test directory with all its files and subdirectories into an archive named<br />

testarchive.tar, use the options -c and -f. For testing purposes, also add -v<br />

to follow the progress <strong>of</strong> the archiving, although this option is not mandatory. After<br />

using cd to change to your home directory where the test directory is located, enter<br />

Working with the Shell 101

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!