[Hampshire] Handling Volume Labels with Spaces

Top Page

Reply to this message
Author: Stephen Davies
Date:  
To: hampshire
Subject: [Hampshire] Handling Volume Labels with Spaces
I'm a bit stuck with a script I'm trying to write for a friend.

He has an EeePC that he is going to use on Holiday to copy Compact Flash
Cards containing his pictures to TWO separate 2.5in HDD's connected to
the USB devices on the PC.
The problem lies in that most of the input media ( The CF Cards ) have
volume labels built in which cannot be changed and these labels contain
space characters.
When the O/S detects a CF card being inserted, it mounts it as
/media/'volume label'

for example (from the output of a df command )
/dev/sdc1 /media/Test Volume

I can get the volume string using the following

cat /proc/mounts | grep sdc1 | awk '{ print $2 }'

This gives "Test\40Volume"
However this is unusable in commands a the space is translated to "\40"

eg
involume=`cat /proc/mounts | grep sdc1 | awk '{ print $2 }'`
cp -R $involume ${outvol1}/${copy_date}/.

( $outvol1 & $copy_date are setup elsewhere in the script )
The format of $involume is invalid and an error is reported.

Any thoughts on how to make this work would be most welcome.