Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Compress Files on macOS Using Terminal Commands

File compression is a crucial aspect of file management, allowing users to reduce the size of files or combine multiple files into a single archive. On macOS, file compression can be efficiently performed using Terminal commands, which provide a quick and powerful way to manage files directly from the command line.

Examples:

  1. Using the zip Command:

    The zip command is commonly used to compress files into a .zip archive. Here's how you can use it:

    • Open Terminal.
    • Navigate to the directory containing the files you wish to compress. For example, if your files are in the Documents folder, you can use the command:
      cd ~/Documents
    • Use the zip command to compress files. For example, to compress two files named file1.txt and file2.txt into an archive named archive.zip, use:
      zip archive.zip file1.txt file2.txt
  2. Using the tar Command:

    The tar command is used to create compressed archives, typically with the .tar.gz or .tgz extension.

    • To compress files into a .tar.gz archive, use the following command:
      tar -czvf archive.tar.gz file1.txt file2.txt

      Here, -c creates a new archive, -z compresses it using gzip, -v provides verbose output, and -f specifies the filename of the archive.

  3. Using the gzip Command:

    The gzip command compresses individual files. It replaces the original file with a compressed version.

    • To compress a single file, use:
      gzip file1.txt

      This command will replace file1.txt with a compressed file named file1.txt.gz.

  4. Using the unzip and tar Commands to Decompress:

    • To decompress a .zip file, use:
      unzip archive.zip
    • To decompress a .tar.gz file, use:
      tar -xzvf archive.tar.gz

These commands provide a straightforward way to manage file compression and decompression on macOS, leveraging the power of the command line for efficient file handling.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.