how to tar a directory without parent directory

apache, linux, ubuntu

Solution

Try this:

tar -czvf xxx.tar.gz -C /ebs1/xxx/aaa/bbb .

Problem

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?

Original source

Related problems