Tar: Difference between revisions
Jump to navigation
Jump to search
Line 28: | Line 28: | ||
!scope="col"| Type !!scope="col"| Short !!scope="col"| Compress !!scope="col"| Decompress !!scope="col"| ⚪ | !scope="col"| Type !!scope="col"| Short !!scope="col"| Compress !!scope="col"| Decompress !!scope="col"| ⚪ | ||
|- | |- | ||
| '''tar.gz''' || '''-z''' || <code>tar -czvf nginx_20240630-T1519-ZP0800.tar.gz nginx</code> || <code>tar -xzvf nginx_20240630-T1519-ZP0800.tar.gz</code> || | | '''tar.gz''' || '''-z''' || <code>tar -czvf nginx_20240630-T1519-ZP0800.tar.gz nginx</code> || <code>tar -xzvf nginx_20240630-T1519-ZP0800.tar.gz</code> || 🟢 | ||
|- | |- | ||
| '''tar.xz''' || '''-J''' || <code>tar -cJvf nginx_20240630-T1519-ZP0800.tar.xz nginx</code> || <code>tar -xJvf nginx_20240630-T1519-ZP0800.tar.xz</code> || | | '''tar.xz''' || '''-J''' || <code>tar -cJvf nginx_20240630-T1519-ZP0800.tar.xz nginx</code> || <code>tar -xJvf nginx_20240630-T1519-ZP0800.tar.xz</code> || 🟠 | ||
|- | |- | ||
| '''tar.bz2''' || '''-j''' || <code>tar -cjvf nginx_20240630-T1519-ZP0800.tar.bz2 nginx</code> || <code>tar -xjvf nginx_20240630-T1519-ZP0800.tar.bz2</code>|| 🟡 | | '''tar.bz2''' || '''-j''' || <code>tar -cjvf nginx_20240630-T1519-ZP0800.tar.bz2 nginx</code> || <code>tar -xjvf nginx_20240630-T1519-ZP0800.tar.bz2</code>|| 🟡 |
Revision as of 06:22, 30 June 2024
tar --version
Compress
cd /etc/nginx
tar -czvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz sites-enabled
tar --exclude=default -czvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz sites-enabled
Decompress
tar -tzvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz
tar -xzvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz
tar -xzvf chorke-nginx_academia-production-20240628-T2023-ZP0800.tar.gz -C chorke-nginx-academia-production
Explanation
-c: Create a new archive -x: Extract the archive -z: Compress the archive with gzip -v: Verbosely list files processed -t: List the contents of the archive -f: Specifies the name of the archive
Cheatsheet
Type | Short | Compress | Decompress | ⚪ |
---|---|---|---|---|
tar.gz | -z | tar -czvf nginx_20240630-T1519-ZP0800.tar.gz nginx |
tar -xzvf nginx_20240630-T1519-ZP0800.tar.gz |
🟢 |
tar.xz | -J | tar -cJvf nginx_20240630-T1519-ZP0800.tar.xz nginx |
tar -xJvf nginx_20240630-T1519-ZP0800.tar.xz |
🟠 |
tar.bz2 | -j | tar -cjvf nginx_20240630-T1519-ZP0800.tar.bz2 nginx |
tar -xjvf nginx_20240630-T1519-ZP0800.tar.bz2 |
🟡 |
DateTime Format
echo "$(date +'%Y%m%d-T%H%M')-Z$(date +'%z'|tr '+-' 'PM')"
:'
20240628-T2023-ZP0800
├─ 20240628
│ ├─ 2024 « %Y
│ ├─ 06 « m%
│ └─ 28 « %d
├─ -T2023
│ ├─ - « -
│ ├─ T « Time
│ ├─ 20 « %H
│ └─ 23 « %M
└─ -ZP0800
├─ - « -
├─ Z « Zone
├─ P « {P: Plus (+), M:Minus (-)}
└─ 0800 « Time Offset
'
References
| ||