Re: for command

From: Zebrouvis, Lois (zebrouvis@PPG.COM)
Date: Thu Nov 06 2003 - 10:38:09 EST


that is not true for aix or hp-ux - that is a linux issue

-----Original Message-----
From: Harvey, Bruce T. [mailto:BTHarvey@LMUS.LEGGMASON.COM]
Sent: Thursday, November 06, 2003 9:36 AM
To: aix-l@Princeton.EDU
Subject: Re: for command

Keep in mind that the shell creates a subshell to feed the pipe to, such
that if you change a program variable within the 'while' loop, it will not
end up changed after the loop. For example:

variable=2

cat testfile | while read f
do
        variable=3
done

when you reach here, variable is equal to 2

Just a side note to remember that I usually forget at least once every two
years or so.

Bruce T. Harvey
Legg Mason Wood Walker, Inc.
Corporate Technology - UNIX Admin.
Red Run 2nd Floor - Owings Mills, MD
(410) 580-7383 - BTHarvey@LeggMason.com
-------------------------------------------------------

-----Original Message-----
From: Paul LaMadeleine [mailto:plamadeleine@LIGHTBRIDGE.COM]
Sent: Thursday, November 06, 2003 9:22 AM
To: aix-l@Princeton.EDU
Subject: Re: for command

I usually do something like this:

cat testfile | while read line
do
   echo $line
done

At 02:10 PM 11/6/2003 +0000, you wrote:
>Given the following data how do I get the following script to echo each
>line, rather than each string?
>
>for line in `cat testfile`
>do
> echo $line
>done
>
>
>testfile =
>
>hhhh jjjjjjj kkkkkkkkk
>ggggg lllllll mmmmmm
>sssss kkkkk llllll
IMPORTANT: The security of electronic mail sent through the Internet
is not guaranteed. Legg Mason therefore recommends that you do not
send confidential information to us via electronic mail, including social
security numbers, account numbers, and personal identification numbers.

Delivery, and timely delivery, of electronic mail is also not
guaranteed. Legg Mason therefore recommends that you do not send time-sensitive
or action-oriented messages to us via electronic mail, including
authorization to "buy" or "sell" a security or instructions to conduct any
other financial transaction. Such requests, orders or instructions will
not be processed until Legg Mason can confirm your instructions or
obtain appropriate written documentation where necessary.



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:20 EDT