开发者

Creating Alias For List of Arguments in Bash

I was wondering if there's any way to create an alias for a list of arguments.

Considering the following commands:

my_command --class_a_argument_one --clas开发者_Python百科s_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

I want to create two different aliases for each list of arguments so that I could run these two commands using these:

my_command class_a_arguments
my_second_command class_a_arguments
my_command class_b_arguments

Any ideas?


Put your arguments in an array, and then invoke the command using that array.

$ arr1=(-e '\e[32mHello world\e[0m')
$ echo "${arr1[@]}"
Hello world


They're called variables.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜