From f337ba729d7097f719c7033ba8001681a5e0aa1b Mon Sep 17 00:00:00 2001 From: bevilj Date: Sat, 17 Nov 2018 13:34:45 +0000 Subject: [PATCH] interm: update tar page (by @brunnn) git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@243 a672b425-5310-4d7a-af5c-997e18724b81 --- site/pages/cmd/interm/tar.html | 142 ++++++++++++++++++++++----------- 1 file changed, 95 insertions(+), 47 deletions(-) diff --git a/site/pages/cmd/interm/tar.html b/site/pages/cmd/interm/tar.html index 0f9dd90..827bdbe 100644 --- a/site/pages/cmd/interm/tar.html +++ b/site/pages/cmd/interm/tar.html @@ -7,62 +7,110 @@ author: Nicola Brunner title: tar --- -

The tar command is used to create and manipulate streaming archive files, in - other words it is used to compress and extract files and directories. He can - extract from many file formats like: tar, pax, cpio, zio, jar, ar and ISO 9660 - cdrom images and create tar, pax, cpio, ar, and shar archives.

-
+The tar command is used to create and manipulate streaming archive files, in +other words it is used to compress and extract files and directories. He can +extract from many file formats like: tar, pax, cpio, zio, jar, ar and ISO 9660 +cdrom images and create tar, pax, cpio, ar, and shar archives.

Usage:

-

There are different syntaxes for this command:

-
tar {-c} [options] [files | directories]
-

The first one is the default syntax. Where {-c} stays for the - creation of a new archive, [options] for the different flags that - we can use, [files | directories] for the files or directories - that we want to compress.

-

tar {-r | -u} -f archive-file [options] [files | directories]
-tar {-t | -x} [options] [patterns]
-tar [bundled-flags ] [ | ...]
-

The last one shows a “bundled” option word provided for compatibility with - historical implementations.

-
+There are different syntaxes for this command: + +
+tar {-c} [options] [files | directories]
+
+ +The first one is the default syntax. Where {-c} stays for the +creation of a new archive, [options] for the different flags that +we can use, [files | directories] for the files or directories +what we want to compress. + +
+tar {-r | -u} -f archive-file [options] [files | directories]
+tar {-t | -x} [options] [patterns]
+tar [bundled-flags args] [file | pattern ...]
+
+ +The last one shows a bundled option word provided for compatibility with +historical implementations.

Flags:

-

This command has a large number of options, but you just need to remember a - few letters for the most important ones:

+This command has a large number of options, but you just need to remember a +few letters for the most important ones:
    -
  • -c creates a new archive, that contains the specified items.
  • -
  • -r is like -c but appends the new entries to the - archive, requires the -f option.
  • -
  • -u is like -r but adds the new entries only if - the date is newer than the corresponding entry date of the file/directory to - the archive, requires the -f option.
  • -
  • -t lists the archive contents to the terminal output.
  • -
  • -v is used to display the progress of an archive creation in - the terminal.
  • -
  • -f allows to specify the name of an archive.
  • -
  • -x is used to extract files from an archive to the disk.
  • -
  • --exclude does not compress specified files or directories.
  • -
  • --include compresses specified file or directories. It's - important to know that --exclude take precedence over inclusions. - The --include option is useful when you want to filter archives
  • +
  • -c creates a new archive, that contains the specified items.
  • +
  • -r is like -c but appends the new entries to the + archive, requires the -f option. +
  • +
  • -u is like -r but adds the new entries only if + the date is newer than the corresponding entry date of the file/directory to + the archive, requires the -f option. +
  • +
  • -t lists the archive contents to the terminal output.
  • +
  • -v is used to display the progress of an archive creation in + the terminal. +
  • +
  • -f allows to specify the name of an archive.
  • +
  • -x is used to extract files from an archive to the disk.
  • +
  • --exclude does not compress specified files or directories.
  • +
  • --include compresses specified file or directories. It's + important to know that --exclude take precedence over inclusions. + The --include option is useful when you want to filter archives. +
-

If you don’t find here an option that you search, or you are interested to read -more about this command, you can write in your terminal:

-

tar man
-
+If you don't find here an option that you search, or you are interested to read +more about this command, you can write in your terminal: -

Example:

-
tar -cvf archive.zip makesmaller.jpg
-

In this case, we take the file makesmaller.jpg and compress it - to archive.zip. We use the options -cvf, -c - for creating a new archive, -v for displaying the progress of the - operation and -f for specifying the name of the archive. +

+man tar
+
-
tar -cvf archive.zip makesmaller.jpg alsome.txt
-

It’s the same case as before, but we wanted to add also alsome.txt - to archive.zip. +

Examples

+ +
+tar -cvf archive.zip makesmaller.jpg
+
+ +In this case, we take the file makesmaller.jpg and compress it +to archive.zip. We use the options -cvf, -c +for creating a new archive, -v for displaying the progress of the +operation and -f for specifying the name of the archive. + +
+tar -cvf archive.zip makesmaller.jpg alsome.txt
+
+It's the same case as before, but we wanted to add also alsome.txt +to archive.zip. + +
+tar -cvf archive.tar /home/Documents --exclude=/home/Documents/PrivatePictures --exclude=/home/Documents/notme.txt
+
+ +With this command we can create an archive named archive.tar of +the /home/Documents directory, but we won't include the +PrivatePictures directory and the file notme.txt, +both are contained in /home/Documents. + +
+tar -cvf archive.tar /home/Music --exclude=*.mp4
+
+ +In this special case we exclude from the archive.tarall the +files which ends in .mp4 and are contained in the directory /home/Music. + +
+tar -cvf archive.zip /home/Music --include=*.mp3
+
+ +In this case we include only the files from the directory /home/Music +that ends in .mp3 to the archive.zip. + +
+tar -xvf archive.zip
+
+It's the same as the archive creation command we used above in the first +example, except the -x option replaces the -c option. +This specifies you want to extract an archive instead of creating one.