I'm new to BASH scripting. I am trying to use variables in commands. What I want is, for example, If the directory "resDir" had the files "patternOne.txt", "patternTwo.txt", "mylist.txt", I'd want the array "arr" to have both "patternOne.txt" and "patternTwo.txt" in it. I am currently doing that this way:
resDir = /home/username/repo/results
str = "pattern"
arr = ($(ls resDir| grep str))
Is this correct or are there any glaring mistakes? Could someone explain when variables need quotations and when they don't?