Command Line Arguments in Shell Script
Command-line arguments are also known as positional parameters. These arguments are specific to the shell script on the terminal during the run time. Each variable passed to a shell script at the command line is stored in corresponding shell variables including the shell script name.
Syntax:
See the below image to understand the command line values and variables. Here ARG1, ARG2 to ARG10 are command-line values, which are assigned to corresponding shell variables.
These are also known as special variables provided by the shell. Except above screenshot, there are some more special variables as given below.
Example Script
Command-line arguments can be passed just after the script file name with space-separated. If any arguments have space, put them under single or double quotes. Read the below simple script.
Now execute this script with 2 arguments and find the following results.
0 Comments
CAN FEEDBACK
Emoji