Need some unix shell basic here:
For command that I see no "-" target in , say ed:
print '%-2p\nq' | ed -s FILE
Can I provide a stream from stdout of some cmd, rather than FILE name, as the data to be processed:
SomeCMD | ed -s SOMETHING_MAGICAL <<< 'print '%-2p\nq'
Is is possible?
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
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:
And a file commands.list contains this:
Then this command line...
Will output this:
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.