Date: Wed, 01 Aug 2007 16:00:45 +0100 From: Tom Evans <tevans.uk@googlemail.com> To: Robert Huff <roberthuff@rcn.com> Cc: questions@freebsd.org Subject: Re: semi OT: sh scripting problem Message-ID: <1185980445.1444.17.camel@localhost> In-Reply-To: <18096.39488.530454.883753@jerusalem.litteratus.org> References: <18096.39488.530454.883753@jerusalem.litteratus.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-o4b4NZ6ZYGO4kiIfYDfY
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
On Wed, 2007-08-01 at 10:35 -0400, Robert Huff wrote:
> (This is probably a FAQ, and I'll take a pointer (or even the
> magic words to identify the problem) instead of an answer.)
> Let's suppose I have a file FILE, with contents:
>=20
> foo
> bar grill
> baz
>=20
> If I do "cat FILE", everything comes out fine.
> If, however, I write a script:
>=20
>=20
> #!/bin/sh
>=20
> for i in `cat FILE`
cat FILE | while read i
> do
> .
> .
> .
> .
> done
>=20
> $i is set to
>=20
> foo
> bar
> grill
> baz
>=20
> Is there a way within the script - or, failing that, by
> modifying FILE - to not break at the whitespace?
>=20
>=20
> Robert Huff
--=-o4b4NZ6ZYGO4kiIfYDfY
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (FreeBSD)
iD8DBQBGsKAZlcRvFfyds/cRAq7yAKCFeo+dXYT2wL3FwRQecqmghQXARACePL6g
ENY9zHZemzocM94t+o5yWuY=
=3fxw
-----END PGP SIGNATURE-----
--=-o4b4NZ6ZYGO4kiIfYDfY--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1185980445.1444.17.camel>
