[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


'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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

650 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