top of page

Shell Script to Accept User Input

Linux bash script allows you to accept user inputs and read what user types on the screen. This is achieved by Linux read command within the script. In the below script, we will be asking user their favorite color and prompt the user with the input they have typed on the screen.


vi user_input_fav_col.sh
# !/bin/bash
echo -n "What is your favourite colour :"
read answer
echo "oh! you like $answer!"

Here is the sample output of the above script

shell script to accept user input

More ways to use User Input Bash Script

  • Ask user to input their name & output "Welcome " + username

  • Ask user to input their first & last name. Output - "Hello " + first + last name


Related Posts

Heading 2

Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

bottom of page