Adding text to the first line of a shell script

the first line of every unix script written in an interpreted language always has a "#!<path-to-the-language>"

is there a way to include other text in that first line without it affecting the ability of the script to run???

for instance, if i change the following line:

#!/bin/sh
echo blah
echo `date`
echo `who`
echo `uptime`

to

#!/bin/sh #...##&#@@@#@#R
echo blah
echo `date`
echo `who`
echo `uptime`

I get the following error:

/bin/sh: #...##&#@@@#@#R: No such file or directory

The ultimate goal here is to remove all lines from a script and have the code in the script be on one line (no matter how long the line ends up being). however, if that cant be done, i can live with just being able to add other text to the first line of the script.

can this be done?

I have no desire to help you write non-portable code that can't be read and understood without reformatting it, but...
Some systems will allow a single argument on the #!shell to be passed to shell when it is run. Some systems will pass more arguments to shell.

Some systems might perform quote removal arguments processed on a #!shell line; most will not. (After all, the kernel evaluating a #!shell line it finds in a file it is exec'ing is not a shell.)

If you happen to be using a system that performs quote removal and allows at least two arguments to be passed to a shell named in a #!shell line, you might get what you want with:

#!/bin/sh -c "whatever command you want to run; and another command; etc..."
2 Likes