OT: Need some shell scripting hints ;)

Jason Gilbert yellowdog-general@lists.terrasoftsolutions.com
Wed Oct 1 15:48:01 2003


This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.

--=_harpua2.doozer.com-19775-1065044857-0001-2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Oct 01, 2003 at 05:28:50PM -0400, nathan r. hruby wrote:
> On Wed, 1 Oct 2003, Alexander Holst wrote:
>=20
> > for LINE in (every line of TextFile.txt)
> > do
> > 	some stuff with $LINE  # for every line one iteration
> > done
> >=20
>=20
> #!/bin/bash
> line=3D`cat file`
> for i in $line; do
>   /bin/something --to $i
> done

I am not a shell expert by any stretch of the imagination.

I found another alternative when trying to do this.

   while read line
   do
      something with $line
   done < "$some_file_name"

My understanding is that it basically hooks up the file contents as standar=
d in
to the read call.  This actually splits the line using the IFS characters as
delimiters (as would happen, I think, in the above example as well) and puts
them into as many variables as are supplied.  I just didn't have any spaces,
etc in my input.  However, look at the man page it appears that if you just
don't supply any variable names after 'read' then the line will be present =
in
$REPLY.  I haven't tried this though.

jason

--=20
"Only two things are infinite, the universe and human stupidity, and I'm not
sure about the former" - Albert Einstein

--=_harpua2.doozer.com-19775-1065044857-0001-2
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/e0t5zR0/8RUKs1MRArE3AJwOcnf4TByffH6ebzFBexoWNBiTxQCgufvS
3kE1TI1/kg+4ZESRIvyQhII=
=UAsY
-----END PGP SIGNATURE-----

--=_harpua2.doozer.com-19775-1065044857-0001-2--