So my web host adds a malware.txt file in my account if there is any. The file has a line with the path to file ending with a : for each line.
I am trying to use awk to print the path from this file and pipe the output into adding into an array. But it's not adding for some reason because when I print nothing happens. If I manually add an element to the array it prints.
Please help me understand how I am wrong.
#!/bin/bash
# Add list of infected files to an array
declare -A malware_listing=()
awk -F":" '/home/{print $1}' ~/malware.txt | while read file ; do malware_listing+=( ${file} ) ; done ;
# Print list of infected files
for i in "${malware_listing[@]}" ; do echo $i ; done ;
~