Skip to content

Instantly share code, notes, and snippets.

@joelagnel
Created September 14, 2023 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joelagnel/254cd2e7ddebd4b1434c0ccbe01e6fce to your computer and use it in GitHub Desktop.
Save joelagnel/254cd2e7ddebd4b1434c0ccbe01e6fce to your computer and use it in GitHub Desktop.
Script to ignore stdin for a $1 seconds
#!/bin/sh
# Check if at least one numeric arg is passed
if [ $# -eq 0 ]
then
echo "Usage: $0 <seconds>"
exit 1
fi
# Read and discard input for 1 second
timeout $1 cat > /dev/null
# Read and print the rest of the input
cat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment