Let's say I have defined a function abc()
that will handle all the logic related to analising the arguments passed to my script.
How can I pass all arguments my bash script has received to it? The number of params is variable, so I can't just hardcode the arguments passed like this:
abc $1 $2 $3 $4
Edit. Better yet, is there any way for my function to have access to the script arguments' variables?
I needed a variation on this, which I expect will be useful to others:
The
"${@:3}"
part means all the members of the array starting at 3. So this function implements a sorted diff by passing the first two arguments to diff through sort and then passing all other arguments to diff, so you can call it similarly to diff: