Emulating the DOS Pause Command

Problem

You are migrating from DOS/Windows batch files and want to emulate the DOS pause command.

Solution

To do that, use the read -p command in a function:

pause ()
{
    read -p 'Press any key when ready...'
}

Discussion

The -p option followed by a string argument prints the string before reading input. In this case the string is the same as the DOS pause command’s output.

See Also

  • help read

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.228.40