5

I'm looking for a program to copy stdin to stdout while showing control characters (like cat -v) and without waiting for an EOF (the input is from a tail -f). I have GNU|Linux; the cat that's installed ignores the -u flag.

2 Answers 2

5

GNU cat ignores -u because its output is always unbuffered. So, when you ask for unbuffered output with -u, you get it (but you also get it even when you don't ask for it).

GNU tail has the same, always-unbuffered behaviour.

To prove this, in one shell I did:

while :; do echo -ne "hello\t"; sleep 1;done > testtail

which appends the word 'hello' followed by a tab, every second (with no newlines)

In another shell I did (cat -T is similar to cat -v -- it shows tabs as ^I):

tail -f testtail | cat -T

which gives me:

hello^Ihello^Ihello^Ihello^I ...

updated every second.

2
4

BSD cat's -u option disabled output buffering. From man cat:

-u      Disable output buffering.
3
  • According to the man page on this machine, -u is ignored. Sep 29, 2012 at 11:21
  • @BlacklightShining Chances are, you're noy using BSD cat
    – Daniel Beck
    Sep 30, 2012 at 11:26
  • Nope, it's GNU cat (or whichever version is standard on Ubuntu). I guess I should've been more specific… Sep 30, 2012 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.