From 3b04aaf8bec3e99e29fe798e04b0540d6599d099 Mon Sep 17 00:00:00 2001 From: Malin Freeborn Date: Tue, 6 May 2025 16:41:57 +0200 Subject: [PATCH] add string substitution --- data/interactive_string_substitution.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 data/interactive_string_substitution.md diff --git a/data/interactive_string_substitution.md b/data/interactive_string_substitution.md new file mode 100644 index 0000000..e4de4b5 --- /dev/null +++ b/data/interactive_string_substitution.md @@ -0,0 +1,19 @@ +--- +title: "Interactive String Substitution" +tags: [ "data", "vim", "substitution" ] +--- + +Want to find and replace, but also confirm each instance? + +```sh +vim -c "%s/${pattern}/${replacement}/gc" -c 'wq' ${file} +``` + +Notice that double-quotes (`"`) in the first command (`-c`). + +Alternatively, check with an example string: + + +```sh +sed "s/${pattern}/ARGLEBARGLE/g" ${file} | grep 'ARGLEBARGLE' +```