There are multiple ways of taking input via the Shell.
1#!/bin/bash
2
3echo "Enter your name:"
4read user_name
5
6echo "Hello $user_name!"
Here’s what the script will look like when we run it.
$ sh nameexample
Enter your name: Sarah
Hello Sarah!
Command line arguments given to a script become variables whose names are numbers. $1
is the first command-line argument, $2
is the second, and so on. $0
is the name by which the script was invoked.