media file explorer download upload index folder image licenses menu widget Play Pause profile-settings more dots-two-horizontal dots-two-vertical more-vertical pending google-plus hangouts facebook instagram whatsapp spotify telegram twitter vine renren rss youtube twitch vimeo flickr dribble behance deviantart 500px steam github soundcloud skype reddit linkedin lastfm delicious stackoverflow pinterest xing flattr foursquare yelp World

Limiting The Number of Entered Characters In read prompt

We previously looked at the way we could utilize the read prompts in bash, here is the script we wrote in out last guide:

#!/bin/bash
read -p "What is Your Name? " name
echo "Your Name is $name"
exit 0

What if we do something as follows:

#!/bin/bash
read -p "What is Your Name? " name
echo "Your Name is $name"
read -n1 -p "Press any key to exit "
echo
exit 0

Now, when the script displays the name, it will pause until you press any key, this is possible by using the -n option followed by an integer, in this case, we specify it to accept just 1 character.