sed not working as intended in bash script -
I am trying to change some strings in the file with sed and I am getting a strange error.
Here is the script ...
#! / Bin / bash template = / etc / nginx / site template if [-f $ template]; Then echo -nother "template $ TEMPLATE was not found." Function Function Usage {echo "Usage: DOMAIN SITEDIR" echo "Example: createsite.sh test.com / var / www / sites / site"} if [-z $ 1]; So if [-z $ 2]; Then use the Fast SDOMAIN = $ 1 SDIR = $ 2 if use [-f / etc / nginx / sites-enabled / $ SDOMAIN]; Then the echo "The site already exists!" SCONFIG = / etc / nginx / sites-enabled / $ SDNN CP $ template exit $ SCONFIG sed -i -e "/% DOMAIN% / $ SDOMAIN / g" $ SCONFIG sed -i "s /% SITEDIR% / $ SDIR / G "$ scanning mkdir $ sdir zone john: www- data $ sdir r-x, nrwx, g + rx $ sdir ngn -t; Then reload the NGN-S "Run nginx reloaded with new site" file
is running it produces low output, and I'm not completely sure why me In fact, an additional set of eyes is required ...
sed: -e expression # 1, char 14: unknown option for `s' nginx: configuration file / etc / nginx / Nginx Conf syntax is ok nginx: The configuration file /etc/nginx/nginx.conf test is reloaded with the successful nginx new site
% SITEDIR%
, if your $ SDIR
is the name of a directory, then first /
The name will be seen as the end of the s ///
command against the data.
The bad answer is to try to get a Sigil which probably will not be possible, for example, if you do not expect to be in a file name from @
then use: Good answer is a completely different tool-awk, perl, and so on. Etc. This is a weird script that does it safely. / P>
Comments
Post a Comment