I have to write script in unix.
When I call it like:
./check -l word1 -c word2,
I need to fetch the word which is used with commands -l and -c from inside script.
I have to write script in unix.
When I call it like:
./check -l word1 -c word2,
I need to fetch the word which is used with commands -l and -c from inside script.
Use getopts
as shown in the following script:
#!/bin/bash
while getopts l:c: option
do
case "$option" in
l)
loption="$OPTARG"
;;
c)
coption="$OPTARG"
;;
esac
done
echo "L is: $loption"
echo "C is: $coption"