![]() ![]() To remove a file from an archive, invoke the -d flag. $ zip home.zip *Įxample 5) Delete a file from an archive (-d) Be sure that you are working in the home directory. If you have multiple files in your current directory, you can zip all of them at a go using the wildcard symbol as shown in the syntax below:įor example, to compress all files in the home directory to home.zip archive, execute the command below. To view contents of a zipped file, use the command as shown: $ zipinfo archive.zipĮxample 4) Zipping all the files in the current directory (* ) For example, to add another file reports4.txt, run: $ zip -u reports.zip report4.txtĮxample 3) View contents of a zipped file To zip them into the archive reports.zip, run the command: $ zip reports.zip reports1.txt reports2.txt reports3.txtĮxample 2) Adding a file to a zip archive (-u)Īt times, you may find the need to add a file to a zip archive. The command for this operation will be: $ zip reports.zip reports1.txtĪdditionally, you can zip multiple files at a go into an archive as shown:Īgain, let’s assume that we have 3 text files reports1.txt, reports2.txt and reports3.txt. Let’s assume you have a text file – reports1.txt – in your current directory and you want to zip it into an archive called reports.zip. When you unzip or extract a file, the user owns the file/directory.Įxample 1) Zipping a single file and multiple files with zip command.You need to have write permissions on the file you are zipping and the directory location before zipping a file.The syntax is quite straightforward:Ī few points to take into consideration before you proceed: Let’s dive in and see how to zip and unzip files and directories in Linux with zip and unzip command with examples. ![]() ![]() Open the terminal and execute the beneath command, $ sudo yum install -y zip unzip $ sudo apt-get install -y zip unzip Install zip & unzip command on CentOS / RHEL / Fedora ![]()
0 Comments
Leave a Reply. |