I'm using the saw and jq plus some filtering to get pretty-printed JSON log streams, but what I have below has no output. It just hangs.
saw watch /aws/ecs/container-log \
| sed -e 's/^\[.*\] \(.*\)(.*)/\1/' \
| tr '\n' '\0' \
| xargs -0 -n1 jq .
>
saw watch streams the container logs, similar to tail -f log.file. I'm using sed to filter out timestamp and log IDs, with the remainder being JSON.
When I just have sed after the watch, it correctly filters out the beginning of the log stream.
saw watch /aws/ecs/container-log \
| sed -e 's/^\[.*\] \(.*\)(.*)/\1/'
> {"data": "..."}
But when I add tr back in, it hangs again.
saw watch /aws/ecs/container-log \
| sed -e 's/^\[.*\] \(.*\)(.*)/\1/' \
| tr '\n' '\0'
>
However, tr on echo works fine.
echo hey | hexdump -c
> 0000000 h e y \n
> 0000004
echo hey | tr '\n' '\0' | hexdump -c
> 0000000 h e y \0
> 0000004
What could be causing this, and how can I fix it?
I'm using
- zsh 5.8 (x86_64-apple-darwin19.3.0)
- macOS 10.15.3
- coreutils: stable 8.31 (installed via brew)
- tr from coreutils
I can't find version for sed, but man sed is marked BSD May 10, 2005.