If gzip isn't available on your system, you can use the compress utility to create a compressed archive (for example, my_) for example (replace file1 and file2 with the names of the files you want to combine): If your system does not use GNU tar, but nonetheless has gzip, you can create a compressed tar archive file (for example my_ with the following command (replace file1 and file2 with the names of the files you want to combine): tar.gz are equivalent both signify a tar archive file compressed with gzip. In the above examples, the -z option tells tar to use gzip to compress the archive as it is created.To use tar and gzip to combine all the files in a directory into a compressed archive file (for example, my_), use the following command (replace /path/to/my/directory with the absolute path to the directory containing the files you want to combine):.To use tar and gzip to combine multiple files into a compressed archive file (for example, my_), use the following command (replace file1 and file2 with the names of the files you want to combine):.If your system uses GNU tar, you can use tar in conjunction with the gzip file compression utility to combine multiple files into a compressed archive file. Many Linux distributions use GNU tar, a version of tar produced by the Free Software Foundation. The -v option tells tar to be verbose (report all files as they are added).If you don't use the -f option, tar will assume you want to create a tape archive instead of combining a number of files.You can use any name in place of my_files.tar, but you should keep the.sh extension (ex: script.sh), which is the extension for the files written with the shell programming language. Open a text editor and save the script with the. txt file is found, the zip command adds ( -u) that file to the ( mynewfiles.zip) ZIP file. txt ( files) extension inside the target directory ( anotherDir). The script then executes a for loop function to search all files with the. The script below declares a variable ( files) to hold the file extension value ( *.txt), then another variable ( targetDir) for the target directory ( anotherDir). Let’s go through what the script below does and how to run it. To do that, you need a script that will repeatedly search for all files with the same extension. To demonstrate how to script some common use cases with the zip utility, perhaps you have a directory with many different files but only need to compress those that match a specific extension. Viewing zip contents without decompressing Zipping Files with the Same File Extension If you’d like to unzip the contents of a ZIP file in a directory other than the working directory, specify the -d followed by the directory to extract the contents of the ZIP file into like: unzip newdir.zip -d anotherdir. By default, the contents are extracted to the same directory ( ~/mydir) of the ( newdir.zip ) ZIP file. Notice the command below will unzip the contents of the ( newdir.zip ) ZIP file. To unzip a ZIP file, launch your terminal and run the following command. Since you’ll still be running commands in a command-line environment throughout this tutorial, let’s start unzipping files via the command-line method. Both methods leverage the unzip package you previously installed to decompress ZIP files. Similar to compressing files, you get two methods for decompressing files, via Command-Line and GUI. But perhaps you need to extract or decompress the contents of the zip file. In the previous examples, you’ve learned how to zip files. Successfully created zip archive Decompressing Files with the Unzip Package The commands below are using the apt package manager to install the zip and unzip packages. To install the zip and unzip packages, launch the terminal on your desktop first and run the commands below depending on the Linux distributions you’re working on.Įach of the commands below begins with the sudo command to handle elevated permissions. Let’s now go through how to install these packages with the apt package manager. To compress and decompress into ZIP files with Linux, you’ll need a couple of packages called zip and unzip. Still, you could also work with other Linux distributions, such as Debian-based (like Unbuntu or Kali Linux), CentOS, or Fedora. The demonstrations throughout this tutorial were made in Kali Linux 2021.2. If you’re an IT pro struggling with too many password reset requests in Active Directory, check out Specops uReset, a secure SSPR solution. Zipping Files with the Same File Extension.Viewing Zip File Contents Without Extracting.Testing the Compressed Files Before Extracting. Decompressing Files with the Unzip Package.Adding New Files to an Existing Zip File.Deleting the Original File after Archiving.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |