[sclug] strip paths from file when tarring?
John Stumbles
john at stumbles.org.uk
Sat Mar 5 23:55:21 UTC 2005
Dickon Hood wrote:
> On Sat, Mar 05, 2005 at 23:05:49 +0000, Darren Davison wrote:
> : On Sat, 2005-03-05 at 21:47 +0000, John Stumbles wrote:
>
> : > like this?
>
> : > tar cjf mytar.tbz2 foo/ bar/; cd long/path/to/; tar cjf mytar.tbz2 \
> : > logfile.log
>
> : > not sure about the flags (cjf) - obviously you want to add the logfile
> : > to the now-existing archive file (and I can't be bottomed to rtfm,
> : > especially as I recall it's a $%&**! info file instead of a proper man
> : > page :-()
>
> : I think the append flag is 'A', but you can't append to a compressed
> : archive, so I guess I have to do..
>
> Ick.
>
> : tar cf mytar.tar foo/ bar/
> : cd long/path/to
> : tar Af ~/mytar.tar logfile.log
> : bzip2 ~/mytar.tar
>
> If they're on the same filesystem, personally I'd probably end up doing
> something reasonably icky as:
>
> ln long/path/to/logfile.log .
> tar cvf - foo bar logfile.log | bzip2 > my.tar.bz2
> rm logfile.log
I was going to suggest something like:
(tar cf - foo/ bar/; cd long/path/to; tar cf - logfile.log) | bzip2
but seems bzip won't compress from stdin. You could do it with gzip...
(I think: haven't tried it but deep within the recesses of my memory
there lurks the notion that you can cat tar archives together.)
--
John Stumbles mobile 0780 866 8204
plumbing:heating:electrical:property maintenance home 0118 954 2406
More information about the Sclug
mailing list