j: Create an archive file using the bzip2 compression z: This creates a tar file using gzip compression r: This option updates a file or directory located inside a. u: Archives a file and then adds it to an existing archive file. t: This option lists all the files inside an archive file. v: Prints verbose information for any tar operation on the terminal. f: Specifies the filename of the archive file. To get familiar with this syntax and go through the examples of this tutorial, look at the parameters below to see what options tar command provides: To tar a folder in Linux, you will use a command kike below: $ tar Join us with this guide to learn how to create archived files with the help of tar command examples. Previously on the OperaVPS blog, you learned How To Unzip Files Using Command On Linux. Compress & Extract File with tar Command in Linux As a compressed file, an archived file contains one or more files that are grouped together for easier storage and transfer. Tar is one of them and in the end, you will be able to extract, create, modify, and list tar archive files. To advance the ideal of tasks, you need to know some essential commands to manage files. In this article, we will explore the ins and outs of the tar command, providing you with a comprehensive guide on how to compress and extract files using this versatile utility. tb2 extension file) tarball to /tmp/bar, enter: $ mkdir /tmp/bar $ tar -jxvf you a Linux user looking for a powerful tool to compress and extract files? Look no further! The tar command in Linux is your go-to solution. tar.bz2/.tbz2/.tb2/.tar.xz archive to specific directory To extract a (.tgz extension file) tarball to /tmp/bar, enter: $ mkdir /tmp/foo $ tar -zxvf -C /tmp/foo Extract. # and dir1 to /tmp/data/ $ tar -xvf $HOME/ file1 file2 file3 dir1 -C /tmp/data Extract. You can extract specific files too: # extract only file1, file2, file3 For example: $ df -H $ du -csh /tmp/data Extract only specific files from a tar archive You can use the df command and du command to view Unix and Linux file system disk space usage too when extracting files. For example: $ cd /tmp/data $ ls -l # Use the grep/ egrep command to filter out results $ ls -l | grep 'filename_here' Use the ls command and cd command to view extracted files. Gif 01: tar Command Extract Archive To Different Directory Command To see a progress pass the -v option: $ tar -xvf $HOME/ -C /tmp/data To extract a tar archive $HOME/ into a /tmp/data, enter: $ tar -xf $HOME/ -C /tmp/data First, you have to create the directory manually using the mkdir command: $ mkdir /tmp/data In this example, I’m extracting $HOME/ file to a directory called /tmp/data. show progress on screenĮxample: Extract files to another directory tar.xz (xz) file format (see how to extract tar.xz files in Linux for more details) -directory : Set directory name to extract files. ![]() tar.bz2/.tar.zx archive? Try: $ tar -jxf file.tar -directory /path/to/directory tar.gz archive: $ tar -zxf file.tar -directory /path/to/directory OR use the following to extract tar files to a different directory: $ tar xf file.tar -directory /path/to/directoryĮxtract. GNU/tar Linux syntax: $ tar xf file.tar -C /path/to/directory Typical Unix tar syntax: $ tar -xf -C /path/to/directory Untarring a file can be done using the following syntax. ![]() Join Patreon ➔ Syntax For Tar Command To Extract Tar Files To a Different Directory ![]() If you enjoy the content, please support us on Patreon or share this page on social media or your blog. nixCraft is a labor of love, and it’s only possible thanks to the support of our readers. You won’t have to deal with pop-ups, ads, cookie banners, or other distractions. nixCraft is designed to be fast and easy to use. ![]() Just pure content in the true spirit of Linux and FLOSS. I don’t track you, show you ads, or spam you with emails. I keep the content accurate and up-to-date. I create all the content myself, with no help from AI or ML.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |