Author: Richard Brown Date: To: stephen.davies, Hampshire LUG Discussion List CC: Subject: Re: [Hampshire] Handling Volume Labels with Spaces
On Fri, Feb 15, 2008 at 11:28 AM, Stephen Davies
<stephen.davies@???> wrote: > I'm a bit stuck with a script I'm trying to write for a friend.
> 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}/.
>
As victor just said, you'll need to quote or escape $involume to use it with cp.
If you're feeling very lazy just add
| sed -e 's#\\40# #'
to the end of your command string, to turn \40 into a space. It's very
fragile though, on my system it's being escaped as \040