Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to tar a directory without parent directory [closed]

I want to compress the contents of:

/ebs1/xxx/aaa/bbb/

So, all the files and folders inside "bbb" I want to be compressed to a file named "xxx.tar.gz" I am using:

tar -zcvf "xxx.tar.gz" "/ebs1/xxx/aaa/bbb/"

It's ok. But when I open the file "xxx.tar.gz" the tree directories start at

/ebs1 -> /xxx -> /aaa -> /bbb ->

and after this I can see the content.

Is it possible to tell tar not to include the parent directories in the compressed files, so when I extract it I dont need to open all directories to get to my content?

like image 842
amandanovaes Avatar asked Oct 16 '25 17:10

amandanovaes


1 Answers

Try this:

tar -czvf xxx.tar.gz -C /ebs1/xxx/aaa/bbb .
like image 109
Matt K Avatar answered Oct 19 '25 06:10

Matt K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!