Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .