Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Feb 2003 13:06:17 +0100
From:      Stijn Hoop <stijn@win.tue.nl>
To:        "Denis N. Peplin" <info@volginfo.ru>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: can't peform blankspace escape - sh command substitution bug or feature?
Message-ID:  <20030212120617.GD3141@pcwin002.win.tue.nl>
In-Reply-To: <200302121506.29923.info@volginfo.ru>
References:  <200302121506.29923.info@volginfo.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

--dFWYt1i2NyOo1oI9
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Feb 12, 2003 at 03:06:29PM +0300, Denis N. Peplin wrote:
> I try to escape blankspace in filenames by using backslash
> First, i'm test sed expression:
> $ sed 's/ /\\ /g'
> long file name
> long\ file\ name
>=20
> this ok.
>=20
> second, include this sed expression in sh command substitution:
> $ filename=3D`echo "long file name" | sed 's/ /\\ /g'` ; echo $filename
> long file name
>=20
> with csh all ok, but with Bourne not. is this bug or feature?
> i'm searched in google and only found different instructions about
> escaping variables by hand...

Escaping inside backticks ` is very tricky. Try this instead:

$ filename=3D$(echo "long file name" | sed 's/ /\\ /g'); echo $filename
long\ file\ name

In /bin/sh, $() is the same construct as ``, see man sh(1).

HTH,

--Stijn

--=20
The right half of the brain controls the left half of the body.  This means
that only left handed people are in their right mind.

--dFWYt1i2NyOo1oI9
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQE+Sji5Y3r/tLQmfWcRAl4cAJsHy5Wk/S0lCNflQlWO6tgz1lZyzQCfRSBC
o2dMM/RfCbhOAe1GX96uXj8=
=dN6S
-----END PGP SIGNATURE-----

--dFWYt1i2NyOo1oI9--

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?20030212120617.GD3141>