new_perl
new_perl

Reputation: 7755

How to write a bash script to execute a different command with additional arguments?

When called as my_cmd -a -b ... c,

the script will finally call program a with addition parameters:

a -additional -a -b ... c

How can I write such a bash script?

Upvotes: 0

Views: 229

Answers (3)

manatwork
manatwork

Reputation: 1750

If the command's name "a" has to be also taken from the my_cmd's parameters:

"${1:1}" -additional "$@"

Upvotes: 0

Jonathan Leffler
Jonathan Leffler

Reputation: 755026

Given that the additional arguments come immediately after the command, it is trivial:

exec a -additional "$@"

The exec is optional.

Upvotes: 1

eudoxos
eudoxos

Reputation: 19085

a -additional "$@" [pad to 30 characters]

Upvotes: 2

Related Questions