2011-07-06 42 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 

我想創建兩個不同的別名的參數每個列表,這樣我可以使用這些運行這兩個命令:

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