# This article used to record tar
usage I learned in my daily work
# Insert latest update at the top of the logs
#
################################################################
# Date Description
# 02/22/2019 list tar content
# 02/21/2019 tar exclude
# 02/20/2019 untar multiple files
# 02/19/2019 tar files
#
################################################################
02/19/2019
tar files into example.tar.gz
tar czf example.tar.gz file1 file2 file3 …
02/20/2019
When untar multiple files, you cannot do this, it will fail
tar zxf file1 file2 file3
The reason please see this link, the solution is to use xargs
instead:
ls *.tar.gz | xargs -i tar xzf {}
Or you can use find
with -exec
find . -maxdepth 1 -name "*.tar.gz" -exec tar zxf '{}' \;
02/21/2019
For example, if you want to tar things inside a folder but exclude some files
tar czf target.tar.gz ./* --exclude='createInstallerTar.sh' --exclude="target.tar.gz" --exclude='pushBIPayload.sh'
If you don’t exclude target.tar.gz, it will tar itself again.
02/22/2019
list tar.gz file content, flag z
sued to distinguish tar or tar.gz
tar ztvf target.tar.gz