/ Published in: Bash
Empties the keyboard buffer. Useful to discard keyboard input during a command execution inside a bash script.
Try this script without this line:
read -t 0.1 -N 255
and enter any garbage ([ENTER] and all) during these 2 seconds window...
The modifiers:
-t 0.1 Tiemout read on 0.1 seconds - so read won't wait to get all 255 characters
-N 255 Read 255 characters, treating any special character ([ENTER], tabs, etc.) as normal characters
Try this script without this line:
read -t 0.1 -N 255
and enter any garbage ([ENTER] and all) during these 2 seconds window...
The modifiers:
-t 0.1 Tiemout read on 0.1 seconds - so read won't wait to get all 255 characters
-N 255 Read 255 characters, treating any special character ([ENTER], tabs, etc.) as normal characters
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/bin/bash echo -n "Type garbage..." sleep 2 echo done. # Empty keyboard buffer # 255 characters should suffice...? read -t 0.1 -N 255 echo -n "Enter value for a: " read a echo "You entered: $a"