On Mon, Mar 04, 2002 at 01:47:03PM +1100, Alister Waller wrote:
> I have a companies file that contains RR and XX
> 
> What I want is for the script to process the export for each company in the
> companies file and check to see if that companies export flag is set to YES,
> if so do the export, if not then miss it out.
> 
> I have an example below:
> 
> #!/bin/bash
> 
> RRexportflag=yes
> XXexportflag=no
> 
> for i in `cat companies`
> do
> 
> if [ $iexportflag = "yes" ] ; then
> 
> ...do some exporting ...
> 
> fi
> done

eval is what you are looking for (see other answers).

can i suggest changing your code to use something like "read" instead:

 have a companies file that contains RR and XX and some flags for each
 (lines like:  XX yes)

 while read company export; do
   echo "doing $company"
   if [ $export = yes ]; then
      .. do some exporting
   fi
 done < companies

you can expand the companies file (and arguments to "read") to cope with
extra per-company options.

"read" reads from stdin, hence the while loop being redirected from
the companies file. see the section on read in the sh manpage.

-- 
 - Gus
-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to