[GRASS-dev] Re: parsing file paths in GRASS Scripts- Windows OS

Hamish hamish_b at yahoo.com
Sat Mar 26 20:12:35 EDT 2011


Markus wrote:
> Here a silly two-line for most of the job:
> 
> cd gui/wxpython/gui_modules/
>
> for i in menuform.py gmodeler.py menu.py prompt.py goutput.py ; do
>   mv $i tmp.py
>   cat tmp.py | sed 's+shlex.split+utils.split+g' > $i
>   rm -f tmp.py
> done
>
> for i in menuform.py gmodeler.py menu.py prompt.py goutput.py ; do
>   mv $i tmp.py
>   cat tmp.py | sed 's+import shlex+import utils+g' > $i
>   rm -f tmp.py
> done

Hi,

just as an aside/random tip, 'sed -i' works very nicely to do
in-place modifications:


cd gui/wxpython/gui_modules/

for file in menuform.py gmodeler.py menu.py prompt.py goutput.py ; do
   sed -i -e 's+shlex.split+utils.split+g' \
          -e 's+import shlex+import utils+g' $file
done



or if you can guarantee no false positives, it reduces to:

sed -i -e 's+shlex.split+utils.split+g' \
       -e 's+import shlex+import utils+g' *.py


all the power, much less mess!


Hamish



      


More information about the grass-dev mailing list