[PLUG] The Right Tool For the Job

Rich Shepard rshepard at appl-ecosys.com
Mon Jul 27 18:41:29 UTC 2015


On Mon, 27 Jul 2015, wes wrote:

> Awk is for modifying existing data.

Wes,

   Yes, it's a pattern-matching language. But, it acts only on the line on
which it matches the pattern.

> You are adding completely new lines, so the best tool for the job would be
> cat.
>
> for filename in /path/to/app/source/*py
>
> do if ! grep wxversion $filename
>
> then echo "import wxversion
> wxversion.select('3.0.2.0')
> import os, time, wx" > $filename.new
>
> cat $filename >> $filename.new
>
> mv $filename.new $filename
>
> fi
>
> done

   Good to know.

Thanks,

Rich



More information about the PLUG mailing list