From owner-freebsd-questions Mon Dec 3 21:32:33 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mailc.telia.com (mailc.telia.com [194.22.190.4]) by hub.freebsd.org (Postfix) with ESMTP id 8F1A537B419 for ; Mon, 3 Dec 2001 21:32:29 -0800 (PST) Received: from d1o913.telia.com (d1o913.telia.com [195.252.44.241]) by mailc.telia.com (8.11.6/8.11.6) with ESMTP id fB45WRi14005 for ; Tue, 4 Dec 2001 06:32:28 +0100 (CET) Received: from ertr1013.student.uu.se (h185n2fls20o913.telia.com [212.181.163.185]) by d1o913.telia.com (8.8.8/8.8.8) with SMTP id GAA08968 for ; Tue, 4 Dec 2001 06:32:27 +0100 (CET) Received: (qmail 9127 invoked by uid 1001); 4 Dec 2001 05:32:26 -0000 Date: Tue, 4 Dec 2001 06:32:26 +0100 From: Erik Trulsson To: Matthew Graybosch Cc: freebsd-questions@freebsd.org Subject: Re: Using spaces within strings in /bin/sh scripts Message-ID: <20011204053226.GA9104@student.uu.se> Mail-Followup-To: Matthew Graybosch , freebsd-questions@freebsd.org References: <200112032116.55282@starbreaker.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200112032116.55282@starbreaker.net> User-Agent: Mutt/1.3.23.2i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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. -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message