Quantcast
Viewing latest article 38
Browse Latest Browse All 41

Bash flush standard input before a read

Is there an easy way in bash to flush out the standard input?

I have a script that is commonly run, and at one point in the script read is used to get input from the user. The problem is that most users run this script by copying and pasting the command line from web-based documentation. They frequently include some trailing whitespace, or worse, some of the text following the sample command. I want to adjust the script to simply get rid of the extra junk before displaying the prompt.


Viewing latest article 38
Browse Latest Browse All 41

Trending Articles