Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Dec 2001 06:32:26 +0100
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Matthew Graybosch <matthew@starbreaker.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Using spaces within strings in /bin/sh scripts
Message-ID:  <20011204053226.GA9104@student.uu.se>
In-Reply-To: <200112032116.55282@starbreaker.net>
References:  <200112032116.55282@starbreaker.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Dec 03, 2001 at 09:28:14PM -0500, Matthew Graybosch wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> I'm trying to write a script to rip an album to wave files, encode 
> each wave file using oggenc, and move them to a specified directory.
> 
> In this script I have several variables, like $ALBUM to store the 
> album title and $TRACK01 to store the title of the first track. 
> Right now I've been using %20 to substitute for spaces, because 
> oggenc freaks out when I feed it a -t ${TRACK01} argument when 
> $TRACK01 is a string with spaces in it.
> 
> I read "man sh" and didn't find an escape code for a space, and I'm 
> not sure why I can't just use: export ALBUM="Ho Drakon Ho Megas".

This is a fairly common problem, with an easy solution.
Just put the variable within double quotes when you *use* it.
Example:


export ALBUM="something with space"
echo "$ALBUM"

The quotes around tells the shell to treat it as a single argument.



-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011204053226.GA9104>