![]() ![]() Lists or displays files within an archive This list of commands show you how to tar a directory in UNIX with examples, as well as compress and uncompress them by modifying the tar command using these options: c With Linux tar, we can create and maintain Archive files. Multiple files can be gathered into one to enhance storage and portability or compressed to make storage space more efficient with the right tar.gz commands and other tar options One definition of an Archive file is a file that contains one or more files along with metadata. As part of Linux, the tar Linux command functions as an essential tool for archiving. This means the top-level directory that is containing the archive files will not be created instead the files will be placed directly in the “ new_name” directory during the extracting process.Tape archives are created using the Linux tar command and extracted with the Linux unzip command. “ –strip-components 1“: Another option we have used is to ask the Tar to remove the first directory component from the file names in the archive. All the extracted files will be placed in the “ new_name” directory, so, change it with whatever name you want to use for your extracted directory. “ –one-top-level= new_name“: This option is used to tell the Tar which directory it must be used to extract the files into, and if it doesn’t exist, it will create the one automatically. In simple words, it will rename the main archive folder name to what you have set and then extract all the files of the archive in it. It will extract the content in a new directory named “ new_name” while stripping the top-level directory from the extracted files. The above command follows the same regular process for extracting the files in the directory where your Archive is present, however with a slight alteration. tar -xzvf -one-top-level= new_name -strip-components 1 Those who want to extract the Tar file content in the same directory with some different folder name can use the given command. Extract Tar in the same directory but with renamed folder: In the given screenshot you can see we didn’t have any folder named “ testfolder” under “/ opt” so the extraction command gave the error for the same. ![]() ![]() Which can also be replaced with the –directory option.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |