Nathan Ringo
Nathan Ringo

Reputation: 1003

Create absolute paths in tar

How do I rewrite file paths to be absolute in tar, other than rewriting the actual tar file? e.g.

$ tree tmp_fs
tmp_fs
├── bin
├── boot
│   └── kernel
├── include
├── lib
└── share
    └── misc
        └── logo

6 directories, 2 files

$ tar cC tmp_fs . | tar t
./
./share/
./share/misc/
./share/misc/logo
./lib/
./boot/
./boot/kernel
./include/
./bin

Ideally, I'd like to find an option to pass to tar that'd make the paths all be absolute (i.e. /boot/kernel instead of ./boot/kernel).

Upvotes: 1

Views: 1500

Answers (1)

seumasmac
seumasmac

Reputation: 2774

If you mean when you're extracting the files, you just extract the tar file to /

For example:

tar -C / -xvf myfile.tar

If you're trying to force the tarfile to extract to a specific location, no matter what the person extracting it specifies, you can't do that. You'd need to include it in some kind of package, such as a .deb or .rpm file.

Upvotes: 1

Related Questions