1

I am finding that when I run this bash script to delete two lines that match the pattern, I get -sed: 1: "/etc/nsmb.conf": extra characters at the end of n command- error when run Here is the code problem lines:

sed -i s/[default]/d /etc/nsmb.conf
sed -i s/signing_required=no/d /etc/nsmb.conf

pretty basic, but not sure of syntax. looking up answers it seems Mac OS X may need extra chars but do not know what they may be. Just trying to remove these two lines in a file:

[default]
signing_required=no

any help is appreciated

vonbraun
  • 69
  • 1
  • 2
  • 5
  • 1
    MacOS sed `-i` expects a file extension, so sed thinks that `s/[default]/d` is your extension. See [sed command with -i option failing on Mac, but works on Linux](http://stackoverflow.com/q/4247068/3266847) – Benjamin W. Mar 30 '17 at 21:21

1 Answers1

0

Try sed "/\[default\]/d;/signing_required=no/d" filename.
It seems that your sed got into the filename, still expecting commands (see Benjamins comment for explanation).

Also [default] matches any line which has at least one of those characters.
Try to see the result before using the "-i".
Then return to using "-i.bak" on the file, as Benjamin has commented, that will provide the extension which seems mandatory on Mac OS. (I am not knowledgable on Mac OS, so credit to @Benjamin on that part.)

Yunnosch
  • 26,130
  • 9
  • 42
  • 54