On 2005-07-06, Paul Smith wrote:
>
> The disadvantage of the pipe-to-while method is that each element in the
> pipeline is run in a subshell, so variables set inside the while loop
> (for example) won't be set after the loop is complete[*].

find . | {
  while read line
  do
     : whatever
     word=${line%% *}
  done

  : variables set within the loop are still available here, e.g.:
  printf "%s\n" "$word"

}

: but not here

-- 
    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
    ==================================================================
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
    <http://www.torfree.net/~chris/books/cfaj/ssr.html>


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to