Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Linux Timesaving Techniques For Dummies.pdf
Скачиваний:
59
Добавлен:
15.03.2015
Размер:
15.98 Mб
Скачать

Adding Functionality to tar with Complex Commands

85

4. Check the Re-create Folders box to restore the folder structure.

We’ve never encountered a case where we didn’t want to re-create folders. If you don’t select the Re-create Folders check box, all the subdirectories and their contents end up in your current directory. Cleaning up the unpacked pile of structureless files wastes time.

5. Check the Overwrite Existing Files box to replace any file with a duplicate name in your folder.

6. Check the Do Not Extract Older Files box to preserve the most recent copy of the file.

If the copy on your computer is more current than the archived copy, the older file is not extracted. This option works only if the Overwrite Existing Files option is checked.

7. Check the View Destination Folder After

Extraction box to open a file manager window with your newly unpacked archive.

8. When you’re ready, click OK to unpack the file(s).

If the destination folder doesn’t already exist, File Roller asks if you want to create it.

Inspect suspicious-looking files that are included in a tarball before unpacking it. To do so, right-click the filename and choose View File from the drop-down menu to display the file’s contents. If the file looks questionable, don’t open it!

Adding Functionality to tar with Complex Commands

The File Roller enables you to quickly and easily build or unpack archives, but sometimes using the command line with the tar command is the way to go. The following sections explain how combining

the tar command with other functions can give you extra power when you need it.

Building archives from the command line

You can build simple archives (containing one file or many) with the tar command. Here is a basic tar command to create a gzip-compressed archive:

$ tar -zcvf archivename filestoarchive

If you want to archive multiple files, just list them at the end of the command line (separate the names with a space character).

Compressing an archive increases the time it takes to create the archive. If you don’t need to transfer the file over the Web or if the data is already compressed (such as RPMs), skip the -z or -j options when you create the archive.

tar has a lot of powerful options, the most useful of which are listed in Table 13-1.

TABLE 13-1: USEFUL TAR OPTIONS

Option

What It Does

-z

Compress to (or uncompress from) gzip

 

form.

-j

Compress to (or uncompress from) bzip2

 

form.

-c

Create an archive.

-x

Extract from an archive.

-t

Display a list of the files in the archive.

-v

Verbose — tell me what you’re doing.

-f file

Write to (or read from) the archive file.

 

 

Enter man tar at the command line for a complete listing of tar options and flags.

The GNU man pages are handy, but they can be a bit overwhelming at times. Take a deep breath and remember that you can close the page at any time by entering q.

Соседние файлы в предмете Операционные системы