1

It is not duplicate, other questions on stackexchange are about getting rid of this message as archive is created.

Is it possible, given archive that was created with -P option (with leading `/')?

I have an archive created with "--absolute-names" (-P option) - with leading /.

I want to unpack it, with / stripped (tar is doing it by default).

It is almost ideal, but I want to silence:

tar: Removing leading `/' from member names.

without removing other messages (so brute force in the form of 2>/dev/null is not a solution).

I found multiple solution how to silence this message during creating archive but none for unpacking. I know about grep -v but it will (a) hide error code from tar (b) add its own error code if message about / is not stripped.

This situation may be replicated with

cd /home/user/tmp
touch a.txt
mateusz@Grisznak:~/Desktop/tmp$ tar --create -P /home/user/tmp > a.tar
mateusz@Grisznak:~/Desktop/tmp$ tar --extract --file=a.tar 

To avoid XY problem: I am unpacking archives created by backup gem (http://backup.github.io/backup/v4/).

1

This seems to do what you want:

tar --extract --xform 's/^\///' --file=a.tar

Per the man page:

--transform, --xform EXPRESSION
      use sed replace EXPRESSION to transform file names

So it still strips the leading slash, but doesn't talk about it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.