Reputation: 68
I'm trying to execute the following command:
`sed 's/49%100%/49%!100%/' /etc/nagios/objects/services.cfg`
but I'm getting this error
-bash: ###############################################################################: command not found
If I try to run it without the back ticks, the command will work.
I've tried the following:
`sed 's/49%100%/49%!100%/' /etc/nagios/objects/services.cfg` 2>&1
`sed 's/49%100%/49%!100%/' /etc/nagios/objects/services.cfg`> /dev/null
but it didn't work.
Upvotes: 1
Views: 7284
Reputation: 42999
You don't need back ticks or $()
to invoke sed
here since your requirement is not to interpret the output of sed
as a command.
If your intention is to modify /etc/nagios/objects/services.cfg
, you could do this:
sed 's/49%100%/49%!100%/' /etc/nagios/objects/services.cfg > /etc/nagios/objects/services.cfg.new
or, to make an in-place edit (when you are absolutely sure that your sed
expression is right):
sed -i 's/49%100%/49%!100%/' /etc/nagios/objects/services.cfg
On BSD systems like macOS, sed -i
needs an argument. The command would be:
sed -i '' 's/49%100%/49%!100%/' /etc/nagios/objects/services.cfg
See these posts for more info on back ticks and its more modern form, $()
:
Upvotes: 6