User Tools

Site Tools


guides:tar

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
guides:tar [2020/08/15 15:20] – [Checking the Contents of a TAR File] wikiadminguides:tar [2022/08/02 11:59] (current) – external edit 127.0.0.1
Line 52: Line 52:
     - ** homework1 ** is the name of the directory you wish to place in the tar file     - ** homework1 ** is the name of the directory you wish to place in the tar file
 <code> <code>
-tar cvzf homework1.tgz homework1+tar cvzf homework1.tgz homework1
 </code> </code>
  
 In the following example the user types ** ls ** to show that the directory homework1 exists.  After that, the tar command to create a tar file is issued.  This command is run in verbose mode so each file or directory is listed as it is added to the tar file.  The example concludes with a listing of the directory showing that the tar file ** homework1.tgz ** has been created. In the following example the user types ** ls ** to show that the directory homework1 exists.  After that, the tar command to create a tar file is issued.  This command is run in verbose mode so each file or directory is listed as it is added to the tar file.  The example concludes with a listing of the directory showing that the tar file ** homework1.tgz ** has been created.
  
-<code bash>+<code>
 $ ls $ ls
 homework1 homework1
Line 80: Line 80:
  
 <code> <code>
-$ls+$ ls
 homework1  homework1.tgz homework1  homework1.tgz
  
Line 91: Line 91:
  
 ===== Extracting files from a TAR File ===== ===== Extracting files from a TAR File =====
 +
 +To extract the contents of a tar file
 +  * The tar file should be located in the current working directory.
 +  * Any files matching those in the tar file will be replaced.
 +
 +In the tar command, ** c ** should be replaced with ** x **, which tells tar to extract the contents of the file.
 +
 +<code>
 +$ tar xzf homework1.tgz
 +</code>
 +
 +In the following example
 +  * The user types ** ls ** to show the contents of the current directory.
 +  * The user issues the tar command to extract the contents of a file.
 +    * The addition of the ** v ** flag tells tar to be verbose, ie show the files as they are extracted.
 +  * The user types ** ls ** again to show that the directory homework1 has been created.
 +  * The user types ** ls -r homework1 ** to show the files have been extracted in the homework1 directory
 +<code>
 +
 +$ ls
 +homework1.tgz
 +
 +$ tar xvzf homework1.tgz 
 +homework1/
 +homework1/Makefile
 +homework1/hello.cpp
 +
 +$ ls
 +homework1  homework1.tgz
 +
 +$ ls -r homework1
 +hello.cpp  Makefile
 +
 +</code>
  
 ===== Tar Files and WinSCP ===== ===== Tar Files and WinSCP =====
 +
 +WinSCP has the ability to deal with tar files.
 +
 +To create a tar file of a directory
 +  * Select the directory
 +  * Right click and select ** File Custom Commands **
 +  * Select ** Tar/GZip **
 +  * {{:guides:tar1.png?nolink|}}
 +  * You may have to allow a new ssh session
 +  * Provide the name for the tar file.
 +  * {{:guides:tar3.png?nolink|}}
 +  * Notice the new tar file is located in the current directory.
 +  * {{:guides:tar4.png?nolink|}}
  
  
  
guides/tar.1597504837.txt.gz · Last modified: 2022/08/02 11:59 (external edit)