HOWTO: Create a Tar Archive From a File List
I had a list of files that someone requested. I wanted to put them in a tar archive, but the tar on the box doesn’t have an option to add a list of files. Huh. Well, this is quick and dirty, and will choke if you have any space in the filenames, but it met my purposes:
[root /root]# cat manifest.txt /usr/bin/top /usr/bin/slocate /bin/login /bin/xlogin /bin/ls /usr/bin/find /usr/bin/dir /usr/sbin/lsof /usr/bin/md5sum /sbin/syslogd /usr/bin/pstree [root /root]# tar cfvz forhans.tar.gz `cat manifest.txt` tar: Removing leading `/' from member names bin/ps sbin/ifconfig bin/netstat usr/bin/top usr/bin/slocate bin/login tar: /bin/xlogin: Cannot stat: No such file or directory bin/ls usr/bin/find usr/bin/dir tar: /usr/sbin/lsof: Cannot stat: No such file or directory usr/bin/md5sum sbin/syslogd usr/bin/pstreetar: Error exit delayed from previous errors [root /root]# tar tfvz forhans.tar.gz -r-xr-xr-x root/root 60080 2000-03-07 12:03:26 bin/ps -rwxr-xr-x root/root 49488 2000-06-13 20:14:25 sbin/ifconfig -rwxr-xr-x root/root 80632 2000-06-13 20:14:25 bin/netstat -r-xr-xr-x root/root 34896 2000-03-07 12:03:26 usr/bin/top -rwxr-sr-x root/slocate 27052 2003-12-24 05:21:35 usr/bin/slocate -rwxr-xr-x root/root 21672 2002-07-30 10:14:02 bin/login -rwxr-xr-x root/root 47052 2003-12-27 06:00:42 bin/ls -rwxr-xr-x root/root 54544 2000-02-02 15:43:28 usr/bin/find -rwxr-xr-x root/root 47052 2003-12-27 06:00:42 usr/bin/dir -rwxr-xr-x root/root 14844 2000-02-07 07:50:27 usr/bin/md5sum -rwxr-xr-x root/root 27112 2000-09-26 21:03:21 sbin/syslogd -rwxr-xr-x root/root 11376 2000-02-04 22:03:22 usr/bin/pstree
Responses
Brian
cpio can make tar files, and it takes lists :)
Michael
I need a .tar made for me, but sadly I’m on Windows.
Is there any chance that there’s a program that will create one for me on Windows, or is there anyone out there that will create one out of my file (It’s about 22 megs uncompressed) and send it back?
Thanks ^.^
— Michael
Rick
Michael,
You probably don’t need this any more (3 years later), but for those who might find this through Google (as I did), this may come in handy.
You’ll need some sort of Unix-y command substitute (e.g. cygwin), but you’ve probably already got it since you’re trying to use tar. Anyways, this will do it for you:
touch my.tar && cat my.manifest | xargs tar rvf my.tarWorks for me!
Eugene
Rick,
your post has helped me :-)
thanx
Nicolette
Rick, your post helped me too :)
Marie
If you are using a GNU version of tar, you can use the –from-files option, e.g.:
tar czf tonals2010-01-10.tgz –files-from tonal-files.txt
where tonal-files.txt contains a list of files.
Happy tarring,
Marie
Bruce
On Windows you can use 7-zip (http://7-zip.org/) for creating archives – it can handle tar, zip, gzip, bzip2 and 7z adds a right-click context menu which is really useful.
Graeme
Thanks Mate, your post just helped me too
Comment
Tiny Print:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>