Linux / UNIX: tar Command Stay In Local / File System When Creating Archive

Linux / UNIX: tar Command Stay In Local / File System When Creating Archive

To create an archive using the tar command that stays within the local file system, you can use the -C option followed by the path to the directory where you want the archive to be created. For example:

tar -cvf archive.tar -C /path/to/local/directory file1 file2 file3
Source:‮al.www‬utturi.com

This will create an archive called archive.tar in the specified directory that contains the files file1, file2, and file3.

You can also use the -C option when extracting an archive to specify the directory where you want the files to be extracted. For example:

tar -xvf archive.tar -C /path/to/local/directory

This will extract the files from archive.tar into the specified directory.

Note that the -C option only works with the tar command, and it is not available with other archiving tools such as gzip or zip.

Created Time:2017-10-29 22:08:57  Author:lautturi