25
Jun
Posted by Derek@TheDailyLinux in Scripting » Add Comment »
How To: Add a “Press Any Key to Continue” Message to a Script
Adding a “Press any key to continue” message to a script is actually quite easy because it’s already built into the read command. Here’s a couple examples of how to use it:
#!/bin/sh echo "A First Method" read -s -n 1 -p "Press any key to continue..." # insert echo here for cleaner output echo echo "A Second Method" echo "Press any key to continue..." read -s -n 1 any_key echo "Now exiting" exit 0
Note: “any_key” was simply a made up name. It can be anything. As always, be sure to take a look at the man page for more information!
Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:
Here are some similar posts that you may be interested in:
There's 0 Comment So Far
Share your thoughts, leave a comment!