- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the Linux Equivalent to DOS Pause?
We know that the Pause command in DOS is used to suspend execution of the batch files and it then displays the message
Strike a key when ready ...
It should also be noted that some versions of DOS also allow a comment to be entered on the same line as PAUSE.
We can make use of the Pause command in a scenario where we want to suspend the execution of a batch file and display the message “Insert Code”, by typing the following command in the terminal
pause Insert Code
So, that was all about the Pause command in DOS, but we want to know how we can achieve the same thing in Linux, since Linux by default doesn’t provide the pause command utility.
There are different approaches we can go for in order to achieve the exact same behavior as of the Pause command, the first and the most common approach is to make use of the read command.
Let’s first learn a few things about the read command.
Read command in the Linux system is used to read from a file descriptor. The read command then splits the line into words.
read [options] [name ...]
We can replace the options placeholder in the syntax shown below with the following options mentioned in the table below
-a array assign the words read to sequential indices of the array variable ARRAY, starting at zero -d delim continue until the first character of DELIM is read, rather than newline -e use Readline to obtain the line -i text use TEXT as the initial text for Readline -n nchars return after reading NCHARS characters rather than waiting for a newline, but honor a delimiter if fewer than
The command that is equivalent to DOS Pause is mentioned below
read -n1 -r -p "Press any key to continue..." key
In the above command there are certain flags that are used. These are −
-n1 − It is used to specify that it only waits for a single character.
-r − Used to put it into raw mode, which is necessary as if we somehow press something like backlash, it doesn’t register until you hit the next key.
-p − it specified the prompt.
key − the key argument is only necessary if you want to know which key they pressed
- What is the Certainty Equivalent Method?
- What is Python equivalent of the ! operator?
- What is the MySQL SELECT INTO Equivalent?
- What is the C++ equivalent of sprintf?
- What is the equivalent of EXCEPT in MySQL?
- What is the PHP stripos() equivalent in MySQL?
- What is the C# equivalent to Java's isInstance()?
- What is the Java equivalent to MySQL's smallint?
- What is the C# equivalent for the Java System.exit(0)?
- What is the C# equivalent of C++ friend keyword?
- What is the C# Equivalent of SQL Server DataTypes?
- What is the equivalent of C# namespace in Java?
- CSS pause property
- MS-DOS Layered Structure