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.
#Linux unzip how to
Let’s dive in and see how to zip and unzip files and directories in Linux with zip and unzip command with examples.
#Linux unzip install
Open the terminal and execute the beneath command, $ sudo yum install -y zip unzip You can use the for loop not only to unzip files, but also for other similar tasks that take longer if you do them one at a time.$ sudo apt-get install -y zip unzip Install zip & unzip command on CentOS / RHEL / Fedora This little skill you learned in this article is especially handy when we need to unpack hundreds of compressed files at once.
Using the Bash for loop, you can accomplish the task of unpacking multiple compressed files at once easily. Use the following command in order to extract multiple 7z files at once. Or, $ for f in *.rar do unrar e “$f” done Extract Multiple 7z files at Once Use the following command in order to unrar multiple rar files at once. Here is how you can achieve the same task through one single command: $ for z in *.tar.xz do tar -xf "$z" done
Here is how you can use the for loop to make the task simple: $ for z in *.tar.xz Let us suppose that a folder contains multiple tar.xz files and we want to extract them simultaneously. Here is how you can achieve the same task through one single command: $ for z in *.zip do unzip "$z" done Here is how you can use the for loop to make the task simple: $ for z in *.zip Let us suppose that a folder, a “zip_files” folder in our case, contains multiple zipped files and we want to extract them simultaneously. You can open it via the System Dash or the key combination Ctrl+alt+T. We use the terminal application for the Ubuntu command line.
Our example zip and tar folders each contain 4 compressed files of type zip and rar. We ran the commands and procedures mentioned in this article on an Ubuntu 22.04 LTS system. This article describes how you can use the for loop to extract multiple files of the following type using the Ubuntu command line: It allows you to perform several similar operations at once. This is where Bash’s for loop comes in handy. It can prove to be quite tedious and illogical to extract the files one by one, typing the commands to extract them one by one. Things get really difficult when we want to do the same task from the command line. In the Ubuntu user interface, this is pretty easy: you just have to select all the files you want to unzip, right-click on them and use the Extract option to unzip them all. Sometimes we need to unzip multiple zipped and rar’ed files at once, all in a single folder.