Andy B wrote:
> Hi Guys,
>
> Wonder if you can , this problem is getting me down.
>
> My script is falling over with a sed problem.
>
> NEWSTORE=JvHCdEMzDegPI
> NPASS=EoWH/Q4hds7nA
>
> sed -e '/bill/s/'"${NEWSTORE}"'/'"${NPASS}"'/g' /tmp/temp
>
> The above sed command works fine when there are no "special characters"
> but when they appear as above i get a sed: command garbled: error.
> Tried a few things with no luck, to escape theses.
>
> Anyone out there that can plz
>
Don't use / delimiters for the substitute,
use some character that would not be in the encrypted password charset.
Maybe ':' maybe ',' maybe ?????
Looks like editing a passwd type file.
You might wish to be more specific.
What if you have a bill and billy?
sed -e "/^bill:/s,${NEWSTORE},${NPASS},g" /tmp/temp
And to make sure you are only changing the passwd field:
(maybe there is another JvHCdEMzDegPI on the line

)
sed -e "/^bill:/s,^\([^:][^:]*:\)${NEWSTORE},\1${NPASS}," /tmp/temp
Why the global "g"? You expect more than one $NEWSTOR per line?