Reputation: 4490
I have a input file containing a sentence like
typedef void * __builtin_va_list;
I want to replace this with
typedef void ** __builtin_va_list;
I tried using sed as follows
sed 's/void * __builtin_va_list/void ** __builtin_va_list/g' FILE.txt
But it is not working. I think it is due to involvement of *'s in expression. How can we handle this kind of scenario?
Upvotes: 1
Views: 52
Reputation: 785196
You can use this search/replace with captured groups and back-references:
sed -r 's/(void \*)( __builtin_va_list)/\1*\2/g' file
typedef void ** __builtin_va_list;
Also remember that *
needs to be escaped since it is special regex meta character.
Upvotes: 1
Reputation: 2972
You need to escape the stars:
sed 's/void \* __builtin_va_list/void \*\* __builtin_va_list/g' FILE.txt
Upvotes: 1