Home > linux > How to stop tar from archiving the root path to files?

How to stop tar from archiving the root path to files?

May 27Hits:1
Advertisement

When I run the following command:

tar cfvz backup.tar.gz /path/to/my/files/* 

It gzips the entire path. So when I unzip the file, I have to go open 4 folders (path -> to -> my -> files) to get to the files I wanted to backup.

How do I make the files show in root of the gzipped file rather then the entire path?

Thanks in advance!

Answers

Try option -C:

tar cvzf backup.tar.gz -C /path/to/my/files/ .

I'm assuming this is in a script so try something like...

pushd /path/to/my/files
tar cfvz backup.tar.gz *
popd

Tar will only include the path specified on the command-line.

Tags:linux, unix, tar

Related Articles

  • How to stop tar from archiving the root path to files?May 27

    When I run the following command: tar cfvz backup.tar.gz /path/to/my/files/* It gzips the entire path. So when I unzip the file, I have to go open 4 folders (path -> to -> my -> files) to get to the files I wanted to backup. How do I make the fil

  • How to unpack a downloaded tar.bz2 archive?October 28

    I downloaded YOONO-Desktop from http://www.yoono.com/, and I try to install it with the following steps: [[email protected] mpatil]# tar xfv yoono-destop-1.8.43.tar tar: yoono-destop-1.8.43.tar: Cannot open: No such file or directory tar: Error is not r

  • How to open ClockworkMod's .tar.a archives?March 27

    To open the TAR archive on my PC, I have to rename the .tar.a to .tar, otherwise my archive manager will say "Archive type unsupported" or similar. Why do they do that, and how to open these archives in a proper way? --------------Solutions-----

  • Tar: avoid archiving of files larger than certain sizeFebruary 8

    I want to archive files (with tar) which are below 3 MB in size. But I also want to retain the directories in which those files exist. (so I cannot use find command). I just want to avoid the files which are above 3 MB in size. How can this be done?

  • Add/update a file to an existing tar.gz archive?May 13

    Is there a way to add/update a file in a tar.gz archive? Basically, I have an archive which contains a file at /data/data/com.myapp.backup/./files/settings.txt and I'd like to pull that file from the archive (already done) and push it back into the a

  • How do I use 7-Zip for Windows to create .tar.gz archives?September 26

    How can I use the 7-Zip CLI (7za.exe) on Windows to create .tgz archives, as I use tar zcvf archive.tgz source_files on Linux? --------------Solutions------------- If you'd like to do it in a one-liner: 7za.exe a -ttar -so archive.tar source_files |

  • find a file within a tar.gz archiveMarch 12

    Is it possible to use the find command so that it searches the files within a tar.gz archive also using wildcards? like find archive.tar.gz --name *foo* --------------Solutions------------- How about just: $ tar tf archive.tar.gz | grep foo Mount the

  • How do you extract a single folder from a large tar.gz archive?March 29

    I am using this command on a 5GB archive tar -zxvf archive.tar.gz /folder/in/archive is this the correct way to do this? It seems to be taking forever with no command line output... --------------Solutions------------- tar stores relative paths by de

  • How to check/test .tar.bz archives?April 19

    I've been using tar with its "--use-compress-prog=pbzip2" function to archive my files then compress them with pbzip2 to get an "*.tar.bz" archive. Afterwards I checked the resulting file with pbzip2's "-t" switch, and it pas

  • Not possible to extract tar.gz archive in CentosOctober 11

    I have just uploaded tar.gz archive to my Centos server from my home Windows 7 computer. Before that, it was extracted from .zip archive. When I try to extract it: tar -xvf file.tar.gz gunzip file.tar.gz It always give me error: "not in gzip format&q

  • Find out the size of a .tar.gz archive in the terminal without unpackingDecember 19

    I have a 32GB .tar.gz archive and I'd like to know the size of the files if I unpack this compressed archive. I'd like to avoid unpacking the archive first and than use e.g. du. Is it also possible to find out the size of the contained files without

  • Deduplicate Files inside multiple .tar.gz archivesFebruary 26

    I take a nightly backup from my Webhosting service as .tar.gz. The Data changed is very little each night (<10MB). I would like to archive these files and deduplicate (solid compression) files across multiple .tar.gz archives without extracting each

  • Removind same *.tar.gz archivesMarch 3

    I have crontab event archives to .tar.gz some folder every N hours. Finally I have collection of .tar.gz files. Now I want remove duplicating archives (created while target files stays unchanged) How can I do that. I tried to perform comparison by ch

  • .tgz file- tar: Unrecognized archive formatMarch 19

    I'm trying to install a 10gen build of mongodb on my local mac running Mountain Lion (10.8.3): I fetch it with curl at: curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.4.tgz > mongodb.tgz But I can't extract the build: Attempt 1: $ tar -zx

  • Extracting a specific file from tar.tgz archive in windows 7June 14

    This has been asked several times but I can't seem to figure out the solution. I have a tar.tgz archive which has .txt files in it. I need to extract a specific file t1.txt from it programatically in Win 7 in one step. I have tried Winzip 14.5, 7Zip

  • Can't extract .tar.xz archive on 13.10 because permission deniedOctober 25

    I used to have Ubuntu 13.04, and also I had installed VLC 2.1.0 with a .tar.xz archive on that, but after the release of 13.10, I removed 13.04 and installed 13.10, so I tried to install VLC 2.1.0 from the normal PPA: sudo add-apt-repository ppa:vide

  • Why does tar complaint that it cannot find the file while extracting the archive?February 9

    I uninstalled xampp and tried to reinstall it but when trying to extract it to the /opt directory, I get the following error: $ sudo tar -xzf xampp-linux-1.8.3-2-installer.run.tar.gz -C /opt tar (child): xampp-linux-1.8.3-2-installer.run.tar.gz: Cann

  • Install tar.bz2 archive?February 27

    I cannot seem to find out how to install a tar.bz2 file. I've Googled it and I've came across two commands, these did not work. I've changed my directory to my downloads folder cd ~downloads after that I've tried these two tar -xjvf Sublime Text 2.0.

  • untar content of folder from tar.gz archive that get's data from STDOUT (wget)September 12

    I want to extract the content of a single folder from a tar.gz archive that get's it's input from the STDOUT of wget. My command looks like this: wget -O - http://example.com/file.tar.gz | tar -C /path/Where/ToExtract/To -xzf - folderToUntar Unfortun

  • Estimate the size of the extracted files before extraction a `tar.gz` archive?November 7

    Before using tar to extract a .tar.gz archive, it is possible to get an estimate of how large the extracted files are in total? --------------Solutions------------- For gzip: $ gzip -l binutils-2.24.tar.gz compressed uncompressed ratio uncompressed_n

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.954 s.