linux:tar
This is an old revision of the document!
tar -flags dest_file_name source_file_or_dir
| Example | Explanation / Remarks |
|---|---|
| tar -czvf /home/user/dest_backup.tgz /var/www/source_dir/*.html | c=create z=use gzip v=verbose f=next param is target file compress all files in source directory into the specified dest file |
| tar -xzvf /home/user/backup_file.tgz /var/www/dest_dir/*.html | extract files in source file into the specified dest directory(??) |
| Using find: | |
| find /var/log -iname '2022-06*.log' -print0 | tar -cvf /var/bu/june.tar –null -T - | |
| find . -type f > list_of_files.txt && tar -czf bu_file.tar.gz -T list_of_files.txt | |
| find . -type f -exec tar -czf {}.tar.gz {} \; | !← TODO! |
| Flag | Same as | Explanation / Remarks |
|---|---|---|
| c | create a new archive file | |
| f | next parameter is the filename | |
| r | --append | append file(s) to tar file |
| t | --list | list contents of file |
| T | next param is filename containing list of files to be tared(!) ← TODO |
|
| v | verbose output - show details while running | |
| x | extract compressed file | |
| z | use gzip compress or uncompress | |
| - | dash, as last symbol → use stdin as input. usually, together with another program like find |
linux/tar.1711149753.txt.gz · Last modified: 2024/03/22 23:22 by levor
