I am using the following script, so as to call a function that is supposed to iterate over an array.
#!/bin/bash
function iterarr {
for item in "$1"
do
echo "$item"
done
}
myarr=(/dir1/file1.md /dir1/file2.md README.md)
iterarr "${myarr[@]}"
However, when I execute it, it gives the following output.
/dir1/file1.md
Why does it print only the first array entry?
edit: What is more, I would like to be able to use an additional argument (besides the array, so if I use '$@', how to I access the second argument?)
Working on Ubuntu 16.04.03 with ...
*$ $(which bash) --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>