PDA

View Full Version : using tar command in a shell script



rohan_ak1
05-10-2008, 05:40 AM
Hello,
I am trying to use the tar command in a shell script to create an archive of files.The filenames are stored in another file.The file names are seperated by a whitespace and each filename is within double quotes.
The file contains file-names in this form :


"/Windows/E/hari treat/IMG_0679.jpg" "/Windows/E/hari treat/IMG_0678.jpg" "/Windows/E/hari treat/IMG_0673.jpg" "/Windows/E/hari treat/IMG_0669.jpg" "/Windows/E/hari treat/IMG_0675.jpg" "/Windows/E/hari treat/IMG_0680.jpg" "/Windows/E/hari treat/IMG_0676.jpg" "/Windows/E/hari treat/IMG_0672.jpg" "/Windows/E/hari treat/IMG_0674.jpg" "/Windows/E/hari treat/IMG_0681.jpg" "/Windows/E/hari treat/IMG_0671.jpg" "/Windows/E/hari treat/IMG_0670.jpg" "/Windows/E/hari treat/IMG_0677.jpg" "/Windows/E/hari treat/Thumbs.db"

I tried using tar in the form : tar -cvf 1.tar `cat filenames.txt` .

tar: "/Windows/E/hari: Cannot stat: No such file or directory

I guess it is reading filenames only till the whitespace.I tried to escape the whitespace using a \ but still same error.What should I do for tar to work properly?

Salem
05-10-2008, 07:03 AM
tar has an option to read filenames from a file itself.
One filename per line, possibly without the ""