2011-07-06 1 views
0

引数のリストのエイリアスを作成する方法があるかどうかは疑問でした。Bashの引数リストのエイリアスを作成する

my_command --class_a_argument_one --class_a_argument_two --class_a_argument_three --class_a_argument_four 

my_command --class_b_argument_one --class_b_argument_two --class_b_argument_three --class_b_argument_four 

my_second_command --class_a_argument_one --class_a_argument_two --class_a_argument_three --class_a_argument_four 

私はこれらを使用して、これらの2つのコマンドを実行できるように、引数の各リストには2つの異なるエイリアスを作成したい:

my_command class_a_arguments 
my_second_command class_a_arguments 
my_command class_b_arguments 

任意のアイデアは、次のコマンドを考慮

答えて

2

変数と呼ばれます。

A="foo bar" 
B="baz qoox" 
my_command $A 
your_command $B 
+0

は、[注意してください...](http://mywiki.wooledge.org/BashFAQ/050) –

+0

ええ、私は知っています。しかし、彼はシェル初心者のようですので、必要に応じてその問題に遭遇するのは良いことです。 – LaC

3

引数を配列に格納し、その配列を使用してコマンドを呼び出します。

$ arr1=(-e '\e[32mHello world\e[0m') 
$ echo "${arr1[@]}" 
Hello world 
関連する問題