6/18/2023 0 Comments Untar tar.gz![]() Thank you for tuning in to our tutorials. The command above extracts files starting with log-*. $ tar -xvf file.tar -wildcards -no-anchored 'log*' ![]() You can also use a pattern to etract files matching a specific pattern. Example to extract pdf files, run the command: tar -fvx -wildcards '*.pdf' Where *.ext is the file extension you wish to extract. To extract files ending with a specific extension, we can use a wildcard pattern as shown: tar -xvf -wildcards '*.ext' You can also use the short version of the command by replacing the -extract and -file parameters with the -xf. If a file is nested inside a set of folders, you can specify the file path as shown in the command syntax below: tar -extract -file= /path/to/file This command will extract the specified file name and save it in the current working directory. To extract the file-example_PDF.1M.pdf, we can run the command: tar -extract -file=sample.tar file-example_PDF_1MB.pdf rw-rw-r- 1 debian debian 1027072 file-sample_1MB.doc rw-rw-r- 1 debian debian 10151438 file_example_TIFF_10MB.tiff ![]() rw-rw-r- 1 debian debian 1028608 file_example_PPT_1MB.ppt rw-rw-r- 1 debian debian 1042157 file-example_PDF_1MB.pdf rw-rw-r- 1 debian debian 1042592 file_example_JPG_1MB.jpg Suppose we have a tar archive with files as shown: total 16660ĭrwxr-xr-x 3 debian debian 4096 Sep 29 17:30. Luckily, tar allows us to extract specific files from an archive without extracting everything. ![]() In some cases, you may come across an instance where you need to extract a single or a set of files from a large tar archive. However, you can compress files in a tar archive using tools such as gzip, xz, bzip2, lzma, lzip, etc. Files in a tar archive are stored in an uncompressed format along with the archive metadata. It is used in packaging a large set of files as a single collection for distribution purposes. Tar archives are one of the most popular file archiving format. rw-r-r- 1 10013 users 2298004 hadisd.3.f_19310101-20190101_200460-99999.nc.In this post, we are going to learn how to use the tar command to extract a single or multiple files from a tar archive. Running the above code gives us the following result: % Total % Received % Xferd Average Speed Time Time Time Currentġ00 433M 100 433M 0 0 5217k 0 0:01:24 0:01:24 -:-:- 5370k We can also use curl in place of wget in the above example. Running the above code gives us the following result − total 500040 Next we list the extracted files to verify the result. Running the above code gives us the following result: - 07:25:18. The wget command downloads the data form the given URL while the tar command does the extraction of the tar.gz files. In this article we will see how to download and extract the file in a single command. But many times it is found that the downloaded file is a zipped file which is in tar format. We can download any required file form the web using the linux terminal.
0 Comments
Leave a Reply. |