sed with optional characters

Dell Precision m65 notebook
May 27, 2010 at 14:36:50
Specs: OS X 10.6.3
Right now I am using the sed command:

sed -i 's/getline(/getlin3(/g' * .c

Unfortunately sometimes the programmers whose code I am using called getline() and sometimes they called getline ().

I was wondering if anyone knows how I can put an optional space into sed so that both get replaced by the same command.



See More: sed with optional characters

May 27, 2010 at 19:31:32
It might be easier to do a search and replace for the string 'getline ()' (replacing it with 'getline()') on the original source file. I do not know enough about using sed to be of any other help, but I hope my suggestion helps a little . . .

Ernie Registered Linux User 247790

Report •

May 28, 2010 at 07:18:04
Try something like this:

sed 's/getline[ ]*(/getlin3(/g' ....

Report •

May 28, 2010 at 08:24:42
Thanks :)

sed -i 's/old string[character to ignore]*rest of old string/new string/g' ./path/

Worked perfectly.

sed -i 's/getline[ ]*(/getlin3(/g' ./src/support/*.c

Report •
Related Solutions

Ask Question