find and replace command for whole directoray issue
see i have one jig.c file in tha开发者_如何学运维t i have statement like
mkvFree(jig);
Now i have used following command for find and replace
find /home/jeegar/jig.c -type f -exec sed -i 's/mkvFree(/mkvFree((void**)&/g' {} \;
By this command i want to get output as
mkvFree((void**)&jig);
But i get output like
mkvFree((void**)mkvFree(jig);
whats wrong with my command ?
Edit :
i have taken this command from https://superuser.com/questions/324428/find-and-replace-command-for-whole-directory
You need to escape the \& character:
find /home/jeegar/jig.c -type f -exec \
sed -i 's/mkvFree(/mkvFree((void**)\&/g' {} \;
The &
character would substitute the whole matched input for the pattern.
&
is a metacharacter in the replacement expression, meaning "the whole search string". Quote it and it should work.
精彩评论