[CDBUG-talk] OT: script help

Garance A Drosihn drosih at rpi.edu
Thu May 13 15:55:09 EDT 2010


At 9:07 AM -0400 5/12/10, Jonathan Franks wrote:
>
>#! /bin/sh
>
>find ./ -type f -name 'FileToFind' -print | while read i
>do
>  sed -i[bak] '$a\
>stuff to append\
>more stuff to append' $i
>done
>
>It works fine in testing, however in practice the absolute
>path to the file(s) contains a directory with a space in
>the name (Thanks, Apple...).
>
>Anyone know of a way to have the path sent to sed in quotes?

I realize you already have a better answer, but to answer the
question as you asked it:

Put the path sent to sed in quotes.  Double-quotes, that is:

do
  sed -i[bak] '$a\
stuff to append\
more stuff to append' "$i"
done

-- 
Garance Alistair Drosehn            =   gad at gilead.netel.rpi.edu
Senior Systems Programmer           or  gad at freebsd.org
Rensselaer Polytechnic Institute    or  drosih at rpi.edu



More information about the CDBUG-talk mailing list