Reputation: 6739
My script takes a list of files as arguments. I want to add new argument to $@
array. For a normal array named files
, appending to the array would be files+=(name_here.png)
. How do to I append to $@
?
Upvotes: 16
Views: 7108
Reputation: 6671
I would refer to @hek2mgl answer as the best array-specific answer, but if your goal is to explicitly extend $@
then go with this:
set -- "$@" '/path/to/file1' '/path/to/file2'
Upvotes: 17
Reputation: 157990
I would copy $@
to an array and append to that:
files=( "${@}" )
files+=( name_here.png )
Then use ${files}
in the script rather than ${@}
.
Upvotes: 8