Operating System - HP-UX
1831661 Members
2070 Online
110029 Solutions
New Discussion

sed script to replace string?

 
Ian McClement
Occasional Contributor

sed script to replace string?

Hi,
Can someone solve a trivial puzzle that has been annoying me for a while.
I just need to search/replace string1 (variable length) in "......... (INITIAL string1 string2 ........."
I have:
sed -e 's/\((INITIAL \)\(.* \)\(.*\)/\1newstring\3/' but cannot remember how to pattern match on "any no of chars except " " instead of .*
Cheers
Ian
1 REPLY 1
Rodney Hills
Honored Contributor

Re: sed script to replace string?

[^ ]*
The up arrow in in square backets means match everything except whats in the square brackets.

Thus this will match any number of non-space characters.

There be dragons...