![]() That will compress existing-directory, existing-file-1, existing-file-2 and all txt files for located in the /path/to/other/place/. It is possible to indicate many paths to files or directories in following way: tar -czvf /path/to/existing-directory /path/to/existing-file-1 /path/to/existing-file-2 /path/to/other/place/*.txt v: verbose output (displays the names of the files as they are being added to the archive) -f: specify the name of the archive file. In this command, the options used are as follows: -r: append files to the end of an archive. Similar to above example when we don't want to print file paths we can remove additionally -v parameter: tar -cf new-archive-name.tar /path/to/existing-directory-or-fileĮxample console output: tar -cf reports_2020-01.tar reports/2020-01/ The syntax for using the tar command for archiving and compressing files is as follows: tar - cxt f tarfile pattern Some of the most common options used along with the tar command are as. To add files to an existing archive, you can use the following command: tar -rvf myarchive.tar myfile2.txt. Where -z parameter was removed to turn off compression mode.Įxample console output: tar -cvf reports_2020-01.tar reports/2020-01/ When we don't want to print file paths we can remove -v parameter: tar -czf /path/to/existing-directory-or-fileīelow example will create not compressed archive, printing progress in console: tar -cvf new-archive-name.tar /path/to/existing-directory-or-file -f allows to select output archive file path (optional).Įxample console output: tar -czvf reports_ reports/2020-01/.-v displays in terminal progress, printing file paths - it is verbose mode (optional),.In the following example, we will combine three files into a single tar archive with no compression. These options will tell the tar command to create a new archive and allow you to specify a filename for the archive, respectively. -c creates new archive for indicated files (required), Those options are c (create) and f (file).Or as: tar -c -z -v -f /path/to/existing-directory-or-file Second one option is more useful when we want to move our files quickly between some devices.īelow example will create compressed archive ( gzip algorithm will be used), printing progress in console: tar -czvf /path/to/existing-directory-or-file packing files together with compression.packing files together without compression,.Quick solution: tar -czvf /path/to/existing-directory-or-file In this short article we are going to show how with tar command we are able to pack or compress files in Linux.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |