0

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.

1
  • @Blender I'm assuming bash shell. Commented Mar 4, 2013 at 8:34

1 Answer 1

0

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"
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.