emacs-ipython-notebook/tools/readme-sed.sh
dickmao 7ce38ffaf0 RFC: readme revision
Requesting comment on README.rst geared towards brevity for new users.
2018-11-29 16:54:30 -05:00

14 lines
436 B
Bash
Executable file

#!/bin/bash
# by mklement0 https://stackoverflow.com/a/29613573/5132008
# Define sample multi-line literal.
input=`cat`
replace=$(awk '/key.*binding/,EOF { print " " $0 }' <<<"$input")
# Escape it for use as a Sed replacement string.
IFS= read -d '' -r < <(sed -e ':a' -e '$!{N;ba' -e '}' -e 's/[&/\]/\\&/g; s/\n/\\&/g' <<<"$replace")
replaceEscaped=${REPLY%$'\n'}
# If ok, outputs $replace as is.
sed "/$1/c\\$replaceEscaped" $2