In BASH Script, I want to read a .ini file with the following contents:
string1=http:xyz/serverx,manager
string2=http:xyz/servery,manager
string3=http:xyz/serverz,manager
Then I want to search occurrences of the three strings in a file. Count them and if the total hits matches a desired number, for example, 99 then echo displaying the count "success with the match count", else echo "failed with the match count"
CodePudding user response:
This should give you what you want:
#!/bin/bash
source strings.ini
count=$(grep -c "${string1}\|${string2}\|${string3}" testfile.txt)
if [ ${count} -eq 99 ]; then
Do whatever you want here....
fi