I know that I can redirect the standard error output stream by: $ ./my-C-binary 2>error.log
What if I want to ignore the first two characters of anything from stderr before writing to the file? I've searched but I can't seem to find a way to do so. I'm not allowed to re-build my-C-binary (i.e. not allowed to change the source code). I am also not allowed to write an additional program to help with the task, it must be solved with a single command line to modify the 2>error.log portion. I don't know how to do that even after a few days of searching and trying.
Let's say the output of stderr is:
The quick brown fox jumps over the lazy dog.
The text in error.log must be:
e quick brown fox jumps over the lazy dog.
Thanks in advance for any suggestions and help.
Combining this answer using process substitution to redirect stderr in bash with @Someprogrammerdude's use of tail
:
./my-C-binary 2> >(tail -c +3 > error.log)
As an aside, note the "+3" parameter to tail: The number indicates the 1-based index of the character where output starts; if you want to skip the first two characters, you start with the third.