I'm trying to make a script which will find a files, take their dirnames and then go there and do something. I have a problem with adding elements to array, who I want to be my dirnames container.
Code looks like this:
dirnames=()
while read -r line; do
echo "Looking for dirname "$line
dirname=$( dirname $(egrep -lir --include=pom.xml "<name>"$line"</name>" $application_dir))
dirnames+=($dirname)
done < $modules_file
echo "Acquired dirnames"
echo $dirnames
And this is the answer:
Looking for dirname a
Looking for dirname b
Looking for dirname c
Acquired dirnames
/home/user/dev/workspace/a
I have only first dir in my "array". It looks like every another iteration is missing, and i know that these other dirnames are found because of i trying to swap lines.
I was reading a lot about arrays in bash, but everywhere this kind of approach works fine.
Any advice?