For example, to create an archive named archive.tar from the files named file1, file2, file3, you would run the following command: tar -cf archive.tar file1 file2 file3. So it always pays to check the contents of big archives before extracting. To create a tar archive, use the -c option followed by -f and the name of the archive. Note: if you use the -P option, tar will archive absolute paths. ![]() You could extract an archive, expect its files to appear in your current working directory, and instead overwrite system files (or your own work) elsewhere by mistake. One is the ability to restore an archive in places other than its original source. Assuming that you have three files in the current directory as follows: Let us verify it with the ls command: ls Here are my tar balls: To untar all. There are very obvious, good reasons why tar converts paths to relative ones. The problem with multiple tar ball files on Linux/Unix. Also, this does the same: tar -C / -xvf foo.tar home/foo/bar # -C is the ‘change directory’ option If you want to simulate absolute paths, do cd / first and make sure you're the superuser. So no, the way you posted isn't (necessarily) the correct way to do it. In the case of my foo.tar file, I could extract /home/foo/bar by saying: tar -xvf foo.tar home/foo/bar # Note: no leading slash zip -r squash.zip dir1 To uncompress: unzip squash.zip this unzips it in your current working directory. To compress: zip squash.zip file1 file2 file3 or to zip a directory. If you need to extract a particular folder, have a look at what's in the tar file: tar -tvf foo.tarĪnd note the exact filename. If you are referring specifically to the Zip file format, you can simply use the zip and unzip commands. ![]() Tar: Removing leading `/' from member names GNU tar even says so if you try to store an absolute path: tar -cf foo.tar /home/foo
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |