Clear keyboard input buffer in Bourne shell 

Newsgroups: comp.unix.shell
>extraneous characters are generated -- and they end up in the keyboard's
>input buffer, so that the next prompt the user sees has these characters
>present (though ...

I'll stick to some generic advice on the subject:

Some systems have a stty command which supports a "flushi" and/or a "flush" option, in which case you can use that.

Otherwise you probably will need to resort to compiling this "flushi" program:

#include <unistd.h>
#include <termios.h>
int main(void) { tcflush(STDIN_FILENO, TCIFLUSH); return 0; }

Some other, more kludgy solutions:

Ken Pizzini