[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash - executing function in "find" command

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
     : whatever
     word=${line%% *}

  : 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

Reply to: