Here's a useful sed one-liner:
echo "printf(\"foo\");" > quotemeonthat
sed -i.bak 's/printf("\(.*\)")/printf("\1 is just too lonely without bar")/' quotemeonthat
cat quotemeonthat
-i.bak - edits the file, preserving the original in quotemeonthat.bak
\1 - refers to the first matched group
output:
printf("foo is just too lonely without bar");
Suggestions for improvements are always welcome :)
No comments:
Post a Comment