[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
value of variable hasn't changed after while loop
From: |
w3 |
Subject: |
value of variable hasn't changed after while loop |
Date: |
Thu, 7 Nov 2002 17:46:51 +0800 |
User-agent: |
KMail/1.4.3 |
Hi,
Why can't I change the value of variable after while loop?
#!/bin/sh
A="cde"
cat /etc/passwd | while read line; do
A="abc" && echo $A
done
echo $A
bash-2.05$ ./test.sh
abc
abc
abc
abc
abc
abc
abc
abc
abc
abc
abc
abc
abc
abc
cde <-- The value of $A hasn't been changed!
Is it a bash bug?
--
w3 <w3@hert.org>
Key ID = 0x5C034369
Key fingerprint = CA07 579E 56A6 9B60 C20E 5B5A 09CE 808A 5C03 4369
http://www.hert.org
- value of variable hasn't changed after while loop,
w3 <=