Shorts
Software packages
SHORT
COMMAND COVERED
curl - Download a file
Download a remote script using curl
This example uses the
curl command with the -fsSL flags to fetch the Homebrew install script from GitHub and then pipes the result to the head command. The -f flag fails silently on server errors, -s suppresses progress output, and -L follows redirects. Piping the output to head shows just the beginning lines of the script. This pattern of using the curl command is commonly used to preview or execute remote installation scripts.
Software packages
SHORT
COMMAND COVERED
tar - manipulate tape archives
Create and inspect a tar archive
This example creates a directory named
mydir and uses the touch command to create only two files inside, a.txt and b.txt. Next, it then archives the contents of the mydir directory using tar -czf, which creates a compressed .tar.gz output file. The options passed to the tar command include the following: the -c flag creates a new archive, -z applies gzip compression, and -f specifies the output filename. Note that the name of the archive, mydir.tar.gz, was specified immediately after the f option, followed by the name of the directory where the files were created. Running tar -tf lists the archive's contents without extracting them, confirming both files were included.
Software packages
SHORT
COMMAND COVERED
zip - package and compress archive files
Create a zip archive using zip
This example uses the
touch command to create two empty files, a.txt and b.txt, and then packages them into a zip archive called archive.zip. The zip command accepts the output filename followed by the files to include in the compressed archive. Running ls -lh afterward shows the archive was created and displays its size, 298B (298 Bytes). Zip archives are widely compatible and a common format for sharing multiple files. See man zip for other options used, as well as related tools such as zipcloak, zipsplit, and others.
Software packages
SHORT
COMMAND COVERED
unzip - compress and extract zip archive
Extract a zip archive using unzip
This example uses the
touch command to create two files, a.txt and b.txt. Next, it archives the files into archive.zip and subsequently deletes the original files to simulate a clean state. Running the ls command confirms the .txt files are gone before the unzip command is used to restore them from the archive. A final ls shows both files are back. This demonstrates how unzip can recover files from a compressed archive.