#!/bin/sed arguments

Self-contained shebang style sed scripts generally look like

#!/bin/sed -f
s/.*/Hello world/

As it has been explained quite well, self-contained sed scripts don't work well with /usr/bin/env. But even without /usr/bin/env putting more than 1 argument after sed might not work. See the following example of GNU sed 4.1.5 on Debian Lenny:

$ cat ./testsed
#!/bin/sed -n -f
$ echo Hello World | ./testsed
/bin/sed: invalid option --
Usage: /bin/sed [OPTION]... (...)

However, it works when you combine the options into one, e.g.

#!/bin/sed -nf


$ echo Hello World | ./testsed
Hello World


Enter your comment. Wiki syntax is allowed:
blog/111023_shebang_sed_arguments.txt · Last modified: 2011-10-23 20:29 by andreas