How to make TAR to not save the directory hierarchy

Posted by Nerian on Super User See other posts from Super User or by Nerian
Published on 2011-02-19T12:23:25Z Indexed on 2011/02/19 15:27 UTC
Read the original article Hit count: 176

Filed under:
|

system("tar -czf #{RAILS_ROOT}/tmp/export-result #{RAILS_ROOT}/tmp/export")

When I decompress the resulting file I get

app/c3ec2057-7d3a-40d9-9a9d-d5c3fe3ffd6f/home/tmp/export/and_the_files

I would like to just get:

export_result/and_the_files

How do I change my TAR call to accomplish this?

solution:

system("tar -czf #{RAILS_ROOT}/tmp/export.tgz --directory=#{RAILS_ROOT}/tmp export/")

© Super User or respective owner

Related posts about tar

Related posts about ruby-on-rails