I'm having problems applying my gawk command to an array of strings.
The gawk command in itself works fine:
$ gawk '$1 == "name" {print $0}' Data1.txt >> Data2.txt
with this I am able to find anything that resembles the word 'name' in column 1 of my first data file, and copypaste the whole line to my second data file.
However, I have to do this procedure a couple of times, and when trying the following, it doesn't seem to retrieve anything:
$ array=("name1" "name2")
$ for i in "${array[$@]}"; do gawk '$1 == $i {print $0}' Data1.txt >> Data2.txt; done
the array itself seems fine, as it works when I replace the gawk command with an echo command. I've also tried to replace $i for "$i", ${i}, "${i}", etc, but this didn't help.
Any idea what I'm doing wrong?? I'm kinda new to Linux, so sorry in advance for my noob question!