![]() You will learn how to list the contents of a tar archive without unpacking it and how to extract only a single file or a single directory. The following article will help you to extract (unpack) and uncompress (untar) – tar, tar.gz and tar.bz2 files from the Linux command line. You can always check its man page to learn about more options.Most of the Linux files that can be downloaded from the Internet are compressed with a tar, tar.gz and tar.bz2 compression formats and it is important to know how to extract such files. Those were some of the most common examples of the unzip command in Linux. In my example, let’s say I don’t want to extract any. You can also exclude certain files or certain type of files from being extracted. You can use the quiet mode with option -q and you won’t see anything on the display: unzip -q -d target_directory zip_file 8. If you extract it, your screen will be cluttered with the output. Now imagine a zip file that has hundreds of files in it. When you unzip a file, it shows all the files that have been extracted on the display. The option -f allows you to do that: unzip -f -d target_directory zip_file 7. In this one, it will update the existing files if they have older timestamp but it won’t create any new files even if they don’ exist. Slight change from the previous example here. You can achieve that with option -u: unzip -u -d target_directory zip_file 6. If a file doesn’t exist, it will be created. In this case, only those files will will be overwritten that have newer timestamp than the existing files. This is slightly different the overwriting all the files. If you don’t want any existing file to be overwritten by newly extracted files, use the -n option (stands for never overwrite). You can force overwrite all the files with option -o. If there are already files with the same name in the directory where you are extracting the files, you’ll be promoted for each such files. Overwrite all the files without prompting The CRC-32 in the output is the cyclic redundancy check. If you want, you can get more information like the compressed size, compression ratio by using the verbose mode with -v option. unzip -l zip_fileĪs you can see, it also shows the timestamp of the files and the actual size of the individual files in bytes. You can use the -l option and it will show the content of the zip file. If you want to see what the zip file contains, you son’t always have to extract it first. See the content of the zip file without extracting You cannot create nested directories in this manner though.ĭo note that you can also put the target directory at the end but not all options can be added at the end. If the target directory doesn’t exist, it will be created. You can specify the target directory where you want to extract the files. The expected behavior is that you should have the files extracted to a certain directory, normally with the same name as the zip file. It’ll just flood your current directory with all the extracted files. If you use it to extract a zip file without any option, it will extract all the files in the current directory: unzip webdesign.zipĪnd that’s not what you would want most of the time. The unzip command has a really simple syntax: unzip zip_file Once you have verified that, let’s see how to use unzip in Linux terminal. On Ubuntu and Debian, you can use this command: sudo apt install unzip You can use your distribution’s package manager to install the command. Before you do that, make sure that unzip has been installed on your system. It’s time to see various usage of the unzip command. I have discussed how to gzip a folder in Linux in the past. ![]() ![]() The unzip command in Linux is quite versatile and you can use it do a lot more than just extracting zip file. If you have a zip compressed file, you can unzip it in the Linux command line.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |