[sed] Replace String in Directory
Question:
Replace strings of the pattern gettext('Archives', DEFAULT_LANG) with 'Archives'|gettext(DEFAULT_LANG) in HTML files under template/ directory.
Answer(inspired by [2], [4], and [5]):
$ cd template/ $ find -type f -name '*.html' | xargs sed -i "s/gettext('\(.*\)', /'\1'|gettext(/g"
References:
[1] | sed process multiple files - Google search sed process multiple files - DuckDuckGo search sed process multiple files - Bing search sed process multiple files - Yahoo search |
[2] | sed - Change multiple files - Stack Overflow |
[3] | sed single quote - Google search sed single quote - DuckDuckGo search sed single quote - Bing search sed single quote - Yahoo search |
[4] | escaping - How to escape single quote in sed? - Stack Overflow |
[5] | xgettext Extract Translatable Strings From Golang html/template |