MODULE-3
read & readonly commands:
The read statement is the shell's internal tool for taking input from the user, i.e. making script
interactive.
Example:
#!/bin/sh #Sample Shell Script - [Link]
echo "Enter Your First Name:"
read fname
echo "Enter Your Last Name:"
read lname
echo "Your First Name is: $fname"
echo " Your Last Name is: $lname"
read only statement:
Shell provides a way to mark variables as read-only by using the read-only command. After a
variable is marked read-only, its value cannot be changed.
For example, the following script generates an error while trying to change the value of NAME –
#!/bin/sh
NAME="Ramu"
readonly NAME
NAME="Bantu”
Command Line Arguments:
✓ Shell script also accept arguments from the command line. They can, therefore, run non-
interactively and be used with redirection and pipelines. When arguments are specified with a
shell script, they are assigned to positional parameters.
✓ The shell uses following parameters to handle command line arguments: