Last active
August 23, 2022 05:32
-
-
Save CMCDragonkai/62c04977f62037285772 to your computer and use it in GitHub Desktop.
BASH: Sed Simple Literal Text Search & Replace
(does not support new lines)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sed-keyword-escape { | |
echo $1 | sed -e 's/[]\/$*.^|[]/\\&/g' | |
} | |
function sed-replace-escape { | |
echo $1 | sed -e 's/[\/&]/\\&/g' | |
} | |
function sed-easy { | |
sed -i "s/$(sed-keyword-escape $1)/$(sed-replace-escape $2)/g" $3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment