😎
CS1.dev
  • Welcome to Computer Science 1
  • Unit 2
    • Activity 2.1
    • Activity 2.2
    • Activity 2.3
    • Activity 2.4
    • Activity 2.5
    • Activity 2.6
    • Activity 2.7
    • Activity 2.9
    • Activity 2.10
    • Project 2
    • Activity 2.8
    • Activity 2.11
    • Activity 2.12
    • Activity 2.13
    • Activity 2.14
    • Activity 2.15
    • Activity 2.16
    • Activity 2.17
    • Activity 2.18
    • Activity 2.19
    • Project 3
    • Activity 2.20
    • Activity 2.21
    • Activity 2.22
    • Activity 2.23
    • Activity 2.24
    • Project 4
    • Activity 2.25
    • Activity 2.26
    • Activity 2.27
    • Activity 2.28
    • Project 5
    • Activity 2.29
    • Activity 2.30
    • Activity 2.31
    • Activity 2.32
    • Activity 2.33
    • Activity 2.34
    • Activity 2.35
    • Activity 2.36
  • Unit 3
    • Activity 3.1
    • Activity 3.2
    • Activity 3.3
    • Activity 3.4
    • Activity 3.5
    • Activity 3.6
    • Activity 3.7
    • Activity 3.8
    • Activity 3.9
    • Activity 3.10
    • Activity 3.11
    • Project 6
    • Activity 3.12
  • Activity 3.13
  • Activity 3.14
  • Activity 3.15
  • Activity 3.16
  • Project 7
  • Activity 3.17
  • Activity 3.18
  • Activity 3.19
  • Project 8
  • Linux
    • bash
    • cat
    • cd
    • chmod
    • df
    • echo
    • find
    • grep
    • less
    • ls
    • mkdir
    • more
    • pwd
    • tar
    • touch
    • unzip
    • zip
Powered by GitBook
On this page
  1. Linux

zip

The zip command in Linux is commonly used for file compression and packaging. It allows you to create .zip files, which are compressed archives containing one or more files or directories. Here are the key functionalities and usage examples of the zip command:

  1. Creating Zip Archives: To create a zip archive, use zip followed by the name of the archive you want to create, and then list the files or directories to be included. For example: zip archive.zip file1.txt file2.txt will create an archive named archive.zip containing file1.txt and file2.txt.

  2. Recursive Compression: To include a directory along with all its subdirectories and files, use the -r (recursive) option. For instance: zip -r archive.zip directoryname will compress the entire directory named directoryname and its contents into archive.zip.

  3. Compression Levels: zip allows specifying the compression level with -0 (no compression) to -9 (best compression). If not specified, zip uses a default compression level. Example: zip -9 archive.zip file.txt uses maximum compression for file.txt.

  4. Excluding Files: If you want to exclude certain files from the zip archive, use the -x option. For example: zip archive.zip * -x exclude.txt will zip all files in the current directory except exclude.txt.

  5. Listing Zip Contents: To view the contents of a zip archive without extracting it, use zip -l archive.zip. This command lists the files included in archive.zip.

  6. Adding Files to Existing Archive: You can add files to an existing zip archive with the same zip command. For example, zip archive.zip newfile.txt adds newfile.txt to archive.zip.

  7. Splitting Zip Files: For large archives, zip can split the file into smaller parts. This is done using the -s option followed by the size (e.g., -s 100m for 100 MB parts).

  8. Zip Options: zip has many options for customization, like adjusting compression method, adding comments to archives, and more.

Previousunzip

Last updated 1 year ago