Unix questions - NIKON directory space in name

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > January 2006 > NIKON directory space in name





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author NIKON directory space in name
John Eley

2006-01-25, 8:38 am

Hi all

I have a CF card in a PCI adapter.
The card is given a name by the camera:

NIKON D70

This is ok from the command line:

ls -l /Volumes/NIKON\ D70
total 32
drwxrwxrwx 1 jeley jeley 8192 Jan 25 12:14 DCIM


But doesn't seem to work from a script:

#!/bin/sh
SRC='/Volumes/NIKON\ D70/DCIM/100NCD70/'

cp -Rv $SRC $DEST
cp: /Volumes/NIKON: open: No such file or directory
cp: D70/DCIM/100NCD70/: open: No such file or directory

Tried to change the name to replace the space in
NIKON D70 with an underscore without luck:

NEW_NAME=$(ls -1 /Volumes/ | grep 'NIKON' | tr ' ' '_' )
SRC='/Volumes/$NEW_NAME/DCIM/100NCD70/'

is there a way to do this?

John
Stephane Chazelas

2006-01-25, 8:38 am

On Wed, 25 Jan 2006 13:38:11 +0100, John Eley wrote:
> Hi all
>
> I have a CF card in a PCI adapter.
> The card is given a name by the camera:
>
> NIKON D70
>
> This is ok from the command line:
>
> ls -l /Volumes/NIKON\ D70
> total 32
> drwxrwxrwx 1 jeley jeley 8192 Jan 25 12:14 DCIM
>
>
> But doesn't seem to work from a script:
>
> #!/bin/sh
> SRC='/Volumes/NIKON\ D70/DCIM/100NCD70/'
>
> cp -Rv $SRC $DEST


Leaving a variable unquoted has a very special meaning for the
shell. You should never do that unless you know what you're
doing and why.

cp -Rv -- "$SRC" "$DEST"

--
Stephane
Rainer Temme

2006-01-25, 8:38 am


Hi John ... try

SRC="/Volumes/NIKON D70/DCIM/100NCD70/"
DST=dest

cp -Rv "$SRC" $DEST

Regards ... Rainer
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com