I’ve got a big string of IP addresses in a bash script stored as a variable.
My question is: How can I verify that all of the IP’s in the string appear the same number of times? If this helps at all, the number of times that all of the IP’s should occur in the string is also stored as a variable.
Here’s an example to show you what I mean:
String "4.2.2.2 8.8.8.8 4.2.2.2 4.2.2.2 8.8.8.8 8.8.8.8"
would be OK
String "1.1.1.1 2.2.2.2 1.1.1.1 2.2.2.2 2.2.2.2"
would not be OK because there are 3 instances of 2.2.2.2 and two of 1.1.1.1
String "4.4.4.4 3.3.3.3 2.2.2.2"
would be OK because they’re all in there once.
or