How to Disable NetBiOS on MacOS OS X
tecklyfe.com
tecklyfe.com
Why not just:
sudo printf "[default]\nport445=no_netbios\n" >> /etc/nsmb.confShell redirection works by opening the destination file and then dup2()'ing it to stdout before exec??()'ing the target program (sudo, in this case) -- since that open fails, the target program is never even run -- and the open()'ing certainly isn't done after sudo runs, since your shell isn't even part of the execution environment at that point (its image having been replaced by sudo's).
Another way to do it, is to invoke a shell that does the redirection after sudo runs, like so:
sudo bash -c '( echo blah; echo blah; echo blah ) >> /etc/nsmb.conf'