PDA

View Full Version : BASH: Passing array of strings to function



kalinichta
2022-06-29, 07:33
Hi there,

I saw that several values can be passed to functions using "{}". Basically I would like to call a function with an array of strings, such as



my_func() {
do_something_with $1
}

my_func {"a" "b" "c"}


I expected the function my_func being called three times and each time another entry of the array would be passed. Am I wrong?

Thanks

Fred Sheehan
2022-07-02, 15:49
https://www.codecademy.com/learn/bash-scripting