Tool: Git Bash for Windows
Problem: Trying to insert the text "\connect central" at the top of each file in a directory.
Code:
for f in $DIR/*.sql; do
sed -i "1i \\\connect central" $f
done
This does try to edit inline and insert my text, but three backslashes (like I've read everywhere) doesn't create the single backslash like I'm expected. Instead I get:
I've also tried some variants along the lines of:
for f in $DIR/*.sql; do
sed -i -e "1i `\\\connect central`" $f
done
but that throws an error of sed: -e expression #1, char 3: expected \ after
a', c',
i'`