joplin-notes/joplin notion extension/linux/Archiving.md
2026-11-04 00:33:23 +05:30

2.5 KiB

Archiving

  • zip and unzip
    • Add files/directories to a specific archive: zip -r path/to/compressed.zip path/to/file_or_directory1 path/to/file_or_directory2 ...

    • Archive files/directories with a specific compression level (0 - the lowest, 9 - the highest): zip -r -0..9 path/to/compressed.zip path/to/file_or_directory1 path/to/file_or_directory2 ...

    • Create an encrypted archive with a specific password: zip -r --encrypt path/to/compressed.zip path/to/file_or_directory1 path/to/file_or_directory2 ...

    • Archive files/directories to a multi-part [s]plit Zip archive (e.g. 3 GB parts): zip -r -s 3g path/to/compressed.zip path/to/file_or_directory1 path/to/file_or_directory2 ...

    • Print a specific archive contents: zip -sf path/to/compressed.zip

    • Excluding directories or files zip -r myarchive.zip target -x "target/exclude1/*" "target/exclude2/*" Exclude all directories within target of particular name(can be nested deep too) zip -r archive_name.zip /path/to/source -x "*/exclude_dir/*"

    • Include hidden directories in zip file find . -mindepth 1 -print | zip archive_name.zip -@

      • find . starts the search in the current directory.
      • mindepth 1 ensures the search does not include the current directory itself (.) in the results.
      • print outputs the found items.

       

    • Extract all files/directories from specific archives into the current directory: unzip path/to/archive1.zip path/to/archive2.zip ...

    • Extract files/directories from archives to a specific path: unzip path/to/archive1.zip path/to/archive2.zip ... -d path/to/output

 

  • 7zip
    • [a]dd a file or directory to a new or existing archive: 7z a path/to/archive.7z path/to/file_or_directory

    • Encrypt an existing archive (including filenames): 7z a path/to/encrypted.7z -ppassword -mhe=on path/to/archive.7z

    • E[x]tract an archive preserving the original directory structure: 7z x path/to/archive.7z

    • E[x]tract an archive to a specific directory: 7z x path/to/archive.7z -opath/to/output

    • E[x]tract an archive to stdout: 7z x path/to/archive.7z -so

    • [a]rchive using a specific archive type: 7z a -t7z|bzip2|gzip|lzip|tar|zip path/to/archive path/to/file_or_directory

    • [l]ist the contents of an archive: 7z l path/to/archive.7z

    • Set the level of compression (higher means more compression, but slower): 7z a path/to/archive.7z -mx=0|1|3|5|7|9 path/to/file_or_directory