I want to write a sed script where the echoing is off, like
#!/bin/sed -n -f
s/x/u/g
but that gives my an
Invalid option -- ' '
error.
How can I do this?
It's because you tried to pass more than one argument in the shebang. Compare:
In this particular case you can compact -n -f
to -nf
. In general this is not always possible. Here the script will be:
#!/bin/sed -nf
s/x/u/g
Note: It seems to me the script in its current form will print nothing because of -n
. I assume you're going to expand it.
LC_ALL=C cat -vt scriptname
and see if it shows anything weird. If that doesn't spot a problem, add info about your OS and version ofsed
. – Gordon Davisson Jan 09 '20 at 08:41-f
without a file name? – choroba Jan 09 '20 at 08:45