[NTLUG:Discuss] Simple bash shell question
. Daniel
xdesign at hotmail.com
Fri Mar 30 15:05:51 CDT 2007
This is probably so elementary that maybe I shouldn't bother asking, but
I'd like to know.
Given the following:
----
#!/bin/sh
fcount=0
ls -1 *.mpg | while read filename ; do
fcount=$(expr $fcount + 1)
echo $fcount
done
echo $fcount
----
why do I get the following output?
----
[daniel at alpha ~]$ test.sh
1
2
3
4
0
----
I would expect:
1
2
3
4
4
Where is my thinking broken?
_________________________________________________________________
春は出会いと別れの季節。メッセンジャーがあれば鬼に金棒!つなげようメッセの輪
http://messenger.live.jp/
More information about the Discuss
mailing list