Here my run.sh file:
#!/bin/sh
before=$(cat <<EOF
require SYSPATH.'core/Bootstrap'.EXT;
EOF
)
after=$(cat <<EOF
if(strpos($_SERVER['SCRIPT_NAME'], 'phpunit'){
sometext # <= without it works fine!
EOF
)
sed -i.bak "s|$before|$after|g" "$2"
error
sed: -e expression #1, char 79: unterminated `s' command
Works fine but I want replace multiline text!
#!/bin/sh
before=$(cat <<EOF
require SYSPATH.'core/Bootstrap'.EXT;
EOF
)
after=$(cat <<EOF
if(strpos($_SERVER['SCRIPT_NAME'], 'phpunit'){
EOF
)
sed -i.bak "s|$before|$after|g" "$2"
cat << 'EOF'
instead ofcat << EOF
if you don't want$_SERVERS
to be expanded to the content of the$_SERVERS
shell variable. – Stéphane Chazelas Feb 09 '17 at 15:29