ed reads its commands from stdin, so if your file is also on stdin, how do you work?
In fact, you can feed file input over stdin, if you concatenate its output with a single line
i
at the beginning, to start writing in the data, then append a single . to end the input, followed by any commands. You can even output the results to stdout. Do remember that it will break if there is a line in the file with nothing but a single . in it.
So if a file input.file contains this:
First line
Second line
Third line
And a file commands.list contains this:
.
1d
1,$w /dev/stdout
Then this command line...
echo i | cat - input.file commands.list | ed -s
Will output this:
Second line
Third line
Dare I say tadaaaaa! ?
Note: you can probably protect against the case of single . lines in the file by piping the file through a filter that escapes any such lines and then unescaping them again with ed commands. I leave that to your ingenuity.
Another note: you really should use sed for this, but I couldn't let the it can't be done comments go by.
SomeCmd | sed '2p;3q'
orSomeCmd | sed '1d;4q'
, etc. – Aero