case statement needs fixing

Cameron Hutchison lists at xdna.net
Fri Nov 20 22:40:09 UTC 2009


James Michael Fultz <croooow at gmail.com> writes:

>* Ray Parrish <crp at cmc.net> [2009-11-19 23:23 -0800]:
>> I have the following code
>> 
>>      while read ThisLine; do
>>            case "$ThisLine" in
>>                 "<loc>"*)
>>                          URLs="$URLs $ThisLine";;
>>            esac
>>      done < "$MapName"
>> echo "URLs $URLs"
>> 
>> Does anyone know why this is not working?

>Loops in a pipeline run are run in a subshell.  There are a few
>solutions to this.

You are correct about loops in a pipeline, but in this case there is
no pipeline, so the URLs assignment will be visible outside the loop.





More information about the ubuntu-users mailing list