You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
413 B
Bash

#!/bin/bash
SEARCH="$1"
REPLACE="$2"
for file in *.md; do
SEARCH="$SEARCH" REPLACE="$REPLACE" perl -i -pe '
BEGIN {
$search = quotemeta($ENV{"SEARCH"});
$replace = $ENV{"REPLACE"};
$replace =~ s/\\/\\\\/g; # escape backslashes in replacement
$replace =~ s/\$/\\\$/g; # escape $ in replacement
}
s/$search/$replace/g;
' "$file"
done
echo "Literal replacement complete."