I have a bunch of folders and files in /usr/local/bin/data that I want to tar.gz.

I have a bash script that sets the source folder to backup src='/usr/local/bin/data/*

When I open up the .tar.gz file, it shows me the folder usr, then local, then bin, then data, etc..

How can I have it tar just the files/folders starting in /data/?


Try using the -C option in Tar:

tar -C /usr/local/bin/ -cvzf foo.tar.gz data

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.