How to Compress a Directory and Add a Comment in Ubuntu
This guide explains how to compress a directory and attach a descriptive comment to the archive file using the Ubuntu terminal. You will learn the specific commands required to create a zip file while embedding text metadata directly into the archive header. This process helps identify file contents without needing to extract them first.
Prerequisites
Ensure the zip utility is installed on your system. Open
your terminal and run the following command to install it if
necessary:
sudo apt install zipCompressing the Directory with a Comment
To compress a folder and add a comment during the process, use the
zip command with the -c and -r
flags. The -r flag ensures the directory is processed
recursively, and the -c flag prompts you to enter a
comment.
Execute the following command, replacing
archive_name.zip with your desired file name and
folder_name with the directory you wish to compress:
zip -c -r archive_name.zip folder_nameAfter pressing Enter, the terminal will display a prompt saying
Enter comment for archive_name.zip:. Type your desired
comment and press Enter to finalize the creation of the archive.
Viewing the Archive Comment
You can view the embedded comment without extracting the files by
using the unzip command with the -z flag. Run
the following command:
unzip -z archive_name.zipThe terminal will display the comment text at the end of the output, allowing you to verify the metadata attached to the compressed directory.