4
I want to tar (and gzip) files without directories and do not store directory paths. I want only flat files in my archive.
For example if I'll do something like this:
tar -czf archive.tgz /home/another/path/*
Then I'll have files with paths in my archive:
home/another/path/file1
home/another/path/file2
home/another/path/file3
But I'd like to have only this:
file1
file2
file3
This is an equivalent of zip's zip -D -j
command.
For simplicity's sake lets assume that there are no subdirectories inside /home/another/path/
- it contains only files.
I tried wit -C
option but it didn't seem to work. With command like this:
tar -C /home/another/path/ -czf archive.tgz *
The tar was trying to archive files in current dir instead of the dir passed to -C
. I'm using (GNU tar) 1.19
.
If I understand your question correctly then this [SO] question How do I tar a directory of files and folders without including the directory itself? should help.
– DavidPostill – 2015-02-26T18:28:01.203@DavidPostill I admit I tried
-C
but it didn't seem to work.*
tarred files in current dir instead of the dir passed to-C
. Any idea why? – SiliconMind – 2015-02-26T18:30:49.397No idea - I'm not a Unix guru -- I just know a little and how to search :/ – DavidPostill – 2015-02-26T18:33:48.900
@SiliconMind any luck trying the answer below? If so it might help others if accepted. – JonathanS – 2015-03-08T03:11:29.763