Re: Scope of Variables in sh

2006-06-01 Thread Michael Schuh
Hello Bob, Hello @Lists, countobjects() { myline=0 cat $objectcountfile|grep -v "^[^0-9]*$"|grep -v "^0$"| awk '{myline += $1} END {print myline}' > $objectsum } this gave me the right behavior. THX i ve forgotten that the piping opens another subshell, so it is clearly logical that the 2

Re: Scope of Variables in sh

2006-06-01 Thread Joseph Koshy
but this doesnt function right. so i see the behavior from $myline in the while-loop like an local variable.. If you are looking for function local variables, use the "local" keyword. For example: a.sh a=1 f() { local a a=2 echo B: In f: $a } echo A: Outside

Scope of Variables in sh

2006-06-01 Thread Michael Schuh
Hello, i have a little problem with the scope of sheel variables in an script. the script shows like: #!/bin/sh objectcountfile=/data2/scout/objects objectsum=/data2/scout/objcount sometime=5 initialize() { [ ! -e $objectsum ] && touch $objectsum } # countobjects() { myline=0 cat $objectcount