my tree
command returns
tmp
`-- t
`-- e
|-- foo.ps
`-- s
|-- bar.ps
`-- t
`-- baz.ps
How can I create archive ps.tar.gz in tmp directory with following structure:
tmp
|-- ps.tar.gz
| |-- foo.ps
| |-- bar.ps
| `-- baz.ps
`-- t
`-- e
|-- foo.ps
`-- s
|-- bar.ps
`-- t
`-- baz.ps
?
for GNU tar you can use the --xform
argument. It takes a sed
expression and applies it on each file name. So for removing all characters up to the last /
, you may use:
tar -c --xform s:^.*/:: your-files
outfile=$(pwd)/ps.tar;find . -type f | while read file; do
tar rf $outfile -C $(dirname $file) $(basename $file)
done
gzip $outfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With