Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prepend to command line arguments in linux/bash

I want to pass along the command line arguments given to script to another command, but I also want to add some additional arguments on the front first. How can I do this with bash?

This will send all the arguments through to the command:

command $@

But I want something more like:

command [argument1, argument2, $@]

How can you do something like this in bash?

like image 303
B T Avatar asked Feb 14 '14 22:02

B T


1 Answers

@ThatOtherGuy's answer is correct.

If you were looking to "unshift" a couple of arguments into the positional parameters, do this:

set -- arg1 arg2 "$@"
cmd "$@"
like image 103
glenn jackman Avatar answered Oct 01 '22 16:10

glenn jackman