User Tools

Site Tools


linux:tar

tar -flags dest_file_name source_file_or_dir

ExampleExplanation / 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! FIXME
FlagSame asExplanation / Remarks
c create a new archive file
f next parameter is the filename
r--appendappend file(s) to tar file
t--listlist contents of file
T next param is filename containing list of files to be tared(!) ← TODO FIXME
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.txt · Last modified: 2024/03/23 16:59 by levor