Você pode fazer 1. com o seguinte comando:
tar cvf archive.tar --transform 's,^,baseFolder/,' a b
O arquivo conterá:
$ tar tvf archive.tar
drwxrwxr-x sylvain/sylvain 0 2015-03-18 12:47 baseFolder/a/
-rw-rw-r-- sylvain/sylvain 0 2015-03-18 12:47 baseFolder/a/foo
drwxrwxr-x sylvain/sylvain 0 2015-03-18 12:47 baseFolder/b/
-rw-rw-r-- sylvain/sylvain 0 2015-03-18 12:47 baseFolder/b/bar
Para 2. você pode executar tar
com várias opções --transform
:
tar cvf archive.tar --transform 's,^a,changed_a,' --transform 's,^b,changed_b,' a b
O arquivo conterá:
$ tar tvf archive.tar
drwxrwxr-x sylvain/sylvain 0 2015-03-18 12:47 changed_a/
-rw-rw-r-- sylvain/sylvain 0 2015-03-18 12:47 changed_a/foo
drwxrwxr-x sylvain/sylvain 0 2015-03-18 12:47 changed_b/
-rw-rw-r-- sylvain/sylvain 0 2015-03-18 12:47 changed_b/bar
Para 3. você pode combinar 1. e 2. como segue:
tar cvf archive.tar --transform 's,^a,changed_a,' --transform 's,^b,changed_b,' --transform 's,^,baseFolder/,' a b
O arquivo conterá:
$ tar tvf archive.tar
drwxrwxr-x sylvain/sylvain 0 2015-03-18 12:47 baseFolder/changed_a/
-rw-rw-r-- sylvain/sylvain 0 2015-03-18 12:47 baseFolder/changed_a/foo
drwxrwxr-x sylvain/sylvain 0 2015-03-18 12:47 baseFolder/changed_b/
-rw-rw-r-- sylvain/sylvain 0 2015-03-18 12:47 baseFolder/changed_b/bar