Press space to continue

You can use read:

read -n1 -s -r -p $'Press space to continue...\n' key

if [ "$key" = ' ' ]; then
    # Space pressed, do something
    # echo [$key] is empty when SPACE is pressed # uncomment to trace
else
    # Anything else pressed, do whatever else.
    # echo [$key] not empty
fi

Replace ' ' for space at above with '' for Enter key, $'\t' for Tab key.


The method discussed in this SO Q&A is likely the best candidate for an alternative to the pause behavior that you're accustom to on Windows when doing BAT files.

$ read -rsp $'Press any key to continue...\n' -n1 key

Example

Here I am running the above and then simply pressing any key, in this case the D key.

$ read -rsp $'Press any key to continue...\n' -n1 key
Press any key to continue...
$ 

References

  • What is the linux equivalent to DOS pause?

You could create a function for it:

pause(){
 read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'
}

Then you can use this everywhere in your script:

pause