![]() ![]() You can do so by appending an -exclude switch for each directory or file you want to exclude. This option must be followed by the name of the tar file. zip would be found and unzipped by entering this command. The sign is a wildcard, which means any number of any characters. ![]() To unzip all the files in that directory.: unzip. f: File, the name of the tar file we want tar to work with. Use the cd command to change to that directory: cd zipped. z: Gzip, use gzip to decompress the tar file. We can also extract an individual file from the WAR, which can be very useful when debugging: unzip baeldung-web-1.0.0.war index.html Archive: baeldung-web-1.0.0.war inflating: index.html. v: Verbose, list the files as they are being extracted. tbz) If your tar file is compressed using a bZip2 compressor, use this. In some cases, you may wish to compress an entire directory, but not include certain files and directories. The command line options we used are: -x: Extract, retrieve the files from the tar file. tgz) If your tar file is compressed using a gZip compressor, use this. Just list as many directories or files as you want to back up. You’d just run the following command: tar -czvf /home/ubuntu/Downloads /usr/local/stuff /home/ubuntu/Documents/notes.txt For example, let’s say you want to compress the /home/ubuntu/Downloads directory, the /usr/local/stuff directory, and the /home/ubuntu/Documents/notes.txt file. Just provide a list of files or directories instead of a single one. How to open or Untar a tar file in Linux or Unix From the terminal, change to the directory where your. While tar is frequently used to compress a single directory, you could also use it to compress multiple directories, multiple individual files, or both. In GNU tar, it is an error to use the z flag if the archive is not compressed with gzip, as you experience now. RELATED: How to Manage Files from the Linux Terminal: 11 Commands You Need to Know The z flag of GNU tar (which is the version of tar shipped with Ubuntu) is used to speciy that the archive being processed is compressed using gzip, which is usually indicated by the. You’d run the following command: tar -czvf /usr/local/somethingĬompress Multiple Directories or Files at Once ![]() Or, let’s say there’s a directory at /usr/local/something on the current system and you want to compress it to a file named. You’d run the following command: tar -czvf stuff Let’s say you have a directory named “stuff” in the current directory and you want to save it to a file named. ![]()
0 Comments
Leave a Reply. |