I am using grep to produce output that will be parsed by another program.
However, that program expects output only to be numeric or zero-bytes.
Now grep outputs a newline character after its output. I’ve checked the -Z option but it doesn’t seem to work as I’m using grep for counting (-c).
I am executing in sh, not bash. So nesting it into echo -n "$(grep -c pattern)" doesn’t work either.
How can I get rid off the trailing newline?
You can pipe it through
trand translate the\nto a\0character: