• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

Bash Spacebar Break

August 16, 2022

Here’s how to add breaks in your Bash scripts. The function is called spacebar.

function spacebar {
  echo 'Press spacebar to continue. Press Ctrl-C to exit.'
  stty -echo > /dev/null
  until read -r -n 1 -t 0.001 && [ "$REPLY" = ' ' ]; do abc=''; done
  stty echo > /dev/null
}
 
spacebar

function spacebar { echo 'Press spacebar to continue. Press Ctrl-C to exit.' stty -echo > /dev/null until read -r -n 1 -t 0.001 && [ "$REPLY" = ' ' ]; do abc=''; done stty echo > /dev/null } spacebar

You can call it multiple times in your script since it’s a function.

Filed Under: Linux Tagged With: bash, continue, hit, spacebar

Search This Website

Subscribe Via Email

  • Home
  • About
  • Archives

Copyright © 2023