#!/bin/sh while getopts l:a: OPT do case $OPT in "l" ) echo "$OPTARG";; "a" ) echo "$OPTARG";; esac done getopts l:a: の部分がオプションの指定。 :(コロン)をつけることで、引数があることを明示。 引数があることを明示した場合、$OPTARGでその引数を取得することができる。 $ ./test.sh -l hoge -a fuga ↓ $ hoge $ fuga と出力される。 参考: http://tech.lampetty.net/tech/index.php/archives/373 Register as a new user and use Qiita more conveniently You get articles that match your needs