'simple' script / tar archive problem

Posted on 2006-10-24
Medium Priority
Last Modified: 2010-05-19

I've the following problem:

When I want to restore multiple files with tar i use the following syntax:

tar -xvf /mnt/usbdrive/backup/vantriest-Fri.tar file1.jpg file2.doc file4.jpg

because of some files have some spaces in the filenames I set the files between comments

tar -xvf /mnt/usbdrive/backup/vantriest-Fri.tar 'file1.jpg' 'file2.doc' 'file4.jpg' 'long filename.jpg'

this works fine .. but not in a script!?!
When I do the exact same thing at the prompt it works fine...
What do i wrong?

the script
cd /mnt/restore

tar -xvf /mnt/usbdrive/backup/deburg-Fri.tar 'mnt/deburg/deBurgMakelaars/deburgmakelaars website/offertedeburg.doc' 'mnt/deburg/deBurgMakelaars/deburgmakelaars website/Onderstaand de aanpassingen die nog uitgevoerd moeten worden.doc' 'mnt/deburg/deBurgMakelaars/deburgmakelaars website/deburg.ppt' 'mnt/deburg/deBurgMakelaars/deburgmakelaars website/zoekcriteria www.deburgmakelaars.nl.doc'

[root@backup backup]# /tmp/commands.sh
mnt/deburg/deBurgMakelaars/deBurgMakelaars website/offertedeburg.doc
tar: mnt/deburg/deBurgMakelaars/deBurgMakelaars website/offertedeburg.doc: Cannot open: No such file or directory
mnt/deburg/deBurgMakelaars/deBurgMakelaars website/Onderstaand de aanpassingen die nog uitgevoerd moeten worden.doc
tar: mnt/deburg/deBurgMakelaars/deBurgMakelaars website/Onderstaand de aanpassingen die nog uitgevoerd moeten worden.doc: Cannot open: No such file or directory
mnt/deburg/deBurgMakelaars/deBurgMakelaars website/deburg.ppt
tar: mnt/deburg/deBurgMakelaars/deBurgMakelaars website/deburg.ppt: Cannot open: No such file or directory
mnt/deburg/deBurgMakelaars/deBurgMakelaars website/zoekcriteria www.deburgMakelaars.nl.doc
tar: mnt/deburg/deBurgMakelaars/deBurgMakelaars website/zoekcriteria www.deBurgMakelaars.nl.doc: Cannot open: No such file or directory


Thanks in advance,

V.R. Jansen
Question by:wanted4u
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

Malohi earned 252 total points
ID: 17796420
First of all you have a difference in you capitalization between the commandline and the script.  This is probably your problem.  deburgmakelaars website is not capitalized on the command line but it is in the script.

If that doesn't work it might not like the quotes.  You can try just escaping the spaces.  You can even do this inside the quotes.  It should look like this: 'deburgmakelaars\ website'

Then the interpreter will know that it is a space and not another file.

LVL 10

Expert Comment

ID: 17872601
Hi Malohi,

use escape charaters of blank spaces

eg mnt/deburg/deBurgMakelaars/deBurgMakelaars website/offertedeburg.doc it is wrong path

actulay it is like  /mnt/deburg/deBurgMakelaars/deBurgMakelaars\ website/offertedeburg.doc  change this then only your scrit work

LVL 10

Assisted Solution

ssvl earned 248 total points
ID: 18026003
or simply use a "

like "mnt/deburg/deBurgMakelaars/deBurgMakelaars website/Onderstaand" it taks the path with spaces

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question