tar command

I have a file with a bunch of absolute path file names. Is there a way with the tar command to read in these files and tar them up?

(I found this list of files using the locate command and I redirected them to a file, and now I want to tar them up)

And if so, when I untar this file that the files will be untarred to say the /tmp/ directory.

I just don't want to untar this file and have the files get untarred to their absolute paths.

I havn't found a way with the tar command yet, but did find something using the find command, or I am just starting to look at the pax command.

Anyone have some hints on a way to do this?

Thanks

You do not state what operating system you are on, if you are on Solaris then the following will tar(1) up all the files listed in the include file:

tar cvf tarfile.tar -I include-file

The trick for enabling the untarring of the files to alternate location is to strip off the leading forward slash from each line of your include file and then create the tar file while located in the root directory.

GNU tar seems to strip off the leading forward slash (/) by default while creating the tar file as mentioned at:
Making backups with tar and seems to support the include file function that Solaris tar(1) does with the:

-T, --files-from F
    get names to extract or create from file F 

parameter.

Personally I would use "cpio" to create the archive unless there was some burning reason to use "tar". The "cpio" program will take file lists from "find .".

Again, the O/S matters and whether you want to explode the archive on a different computer.

If I was doing backups of a Solaris system and it was not using ZFS then I would use ufsdump.

Ah.. The beauty of Unix type systems ... There are at least 3 ways to skin a cat :slight_smile:

Only 3 !?

There are of course many more, starting with pax which can substitute parts of the path on the fly.