某些Sed替换不能用于Bash脚本

I have a script that does a fair bit of sed substitution and it all works baring this one line.

The odd thing is it works fine when I just run it normally on the terminal.

The code I want to substitute is part of this block:

location ~ \.php$ {
  try_files $uri =404;
  fastcgi_pass unix:/var/run/php-fpm.sock;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include fastcgi_params;
}

Particularly this line: fastcgi_pass unix:/var/run/php-fpm.sock; I want to change.

Here's the code I use to attempt to substitute it:

sed -i "s#fastcgi_pass unix:/var/run/php-fpm.sock;#fastcgi_pass unix:/var/run/php7.0-fpm.sock;#" /etc/nginx/sites-available/lemp-stack.app

For some reason it just doesn't substitute.

Does anybody have any ideas?

Thank you.

There might be a tab instead of a space between pass and unix, if it is the case, this should work:

sed "s#fastcgi_pass[ \t]unix:/var/run/php-fpm.sock;#fastcgi_pass unix:/var/run/php7.0-fpm.sock;#"