[sclug] strip paths from file when tarring?

Dickon Hood sclug at splurge.fluff.org
Sat Mar 5 23:10:40 UTC 2005


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

if I couldn't find a nicer way of doing it.

: It just seemed a bit unusually verbose, I assumed I was missing some
: simple option to drop path names when adding to an archive.

You possibly are.  OTOH, you can do wonders with LD_PRELOAD, you know :-)

-- 
Dickon Hood

Due to constant nagging to change it, my .sig is temporarily unavailable.
Normal service will be resumed as soon as possible.  We apologise for the
inconvenience in the meantime.


More information about the Sclug mailing list