Suppose I have a folder structure as follows:
/
parent1
child1
1.log
2.log
child2
parent2
child3
3.log
4.log
child4
parent3
child5
5.log
6.log
Let's say, I would like to add "child1", "child3" and "parent3", then I would like my tar to look like this:
result.tar.gz
myfolder1
1.log
2.log
myfolder2
3.log
4.log
myfolder3
child5
5.log
6.log
So basically, I would like to give my own names to the folders inside the tar, and lose the full path.
Is there any tar/bash magic which can achieve this?
Obviously, I could collect the contents of the selected folders into a new location with the correct structure and then tar that, but I would very much like to do it in 1 line, if possible.