I have a file named Atoms that has a list of atoms listed vertically, like:
O
C
Na
etc. There is a variable number of them.
I want to count their occurences in another file. I want to do this by saving each atom as a variable, preferabbly in an associative array, then counting how many there are in the other file. I already can count the number of atoms, and I save that into $numatoms
My problem right now is the awk command recognizing the variable $i from the for loop. The part where it says NR=="$i" doesn't seem to work. Also, afterward, I still wouldn't know how to count the occurences in another file, which is also based on a variable, titled $name.axyz. I'm fairly new, and help would be appreciated!!! Thanks.
for (( i=1; i < $numatoms; i++ )); do
count[$i]=$(awk {'NR=='"$i"'{ print "$1"}' Atoms)
echo $count[$i]
done