Line Buffered Cat

is there a way to do line-bufferd cat? For example, I want to watch a UART device, and I only want to see it's message when there is a whole line. Can I do some thing like:

cat --line-buffered /dev/crbif0rb0c0ttyS0

Thanks.

3 Answers

You can also use bash to your advantage here:

cat /dev/crbif0rb0c0ttyS0 | while read line; do echo $line; done

Since the read command reads a line at a time, it will perform the line buffering that cat does not.

1

No, but GNU grep with --line-buffered can do this. Just search for something every line has, such as '^'.

5

Pipe it through perl in a no-op line-buffered mode:

perl -pe 1 /dev/whatever

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest