add string substitution

This commit is contained in:
Malin Freeborn 2025-05-06 16:41:57 +02:00
parent 1dfdac516b
commit 3b04aaf8be
Signed by: andonome
GPG Key ID: 52295D2377F4D70F

View File

@ -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'
```