How to use Flags In Linux
Arguments can be passed along with the flags. The arguments can be identified with a single letter having – before that. A single letter can be meaningful and here let us take -1, -2, and -3.
We need to use getopts function to read the flags in the input, and OPTARG refers to the corresponding values:
The above program can be executed as
sh usingFlags.sh -1 ‘w3wiki’ -2 ‘JavaProgramming’ -3 100
Output
Bash Script – How to use Command Line Arguments
In this article, let us see about Command Line Arguments usage in Bash script. Arguments are inputs that are necessary to process the flow. Instead of getting input from a shell program or assigning it to the program, the arguments are passed in the execution part.