-4

Hi i have a variable by counters_new which has few strings, I want to check whether all these given string in the variable counters_new are present in the given file /var/opt/pmconfig/counters.xml I tried:

counters_new= "M806C0, M806C1, M806C2, M806C3, M806C4, M806C5, M806C6, M806C7, M806C8"

if grep -q $(counters_new) "/var/opt/pmconfig/counters.xml";

then

INFO "M806 All Counters found"

else

ERROR "M806 All Counters not found"

endTest FAILED

fi

Cyrus
  • 77,979
  • 13
  • 71
  • 125
  • 3
    Please take a look at [How do I format my posts using Markdown or HTML?](https://stackoverflow.com/help/formatting). – Cyrus Jun 04 '22 at 22:03
  • 3
    See: [Check if all of multiple strings or regexes exist in a file](https://stackoverflow.com/q/49762772/3776858) – Cyrus Jun 04 '22 at 22:11
  • 3
    if this is a bash script, it has several obvious problems. run it through [shellcheck](https://shellcheck.net) and fix those first. Are `INFO`, `ERROR` and `endTest` defined somewhere? – jhnc Jun 04 '22 at 22:38
  • 2
    Please see the formatting you used in your previous 3 questions for how to format your code – Ed Morton Jun 04 '22 at 23:21
  • 1
    You should receive an error like `counters_new: command not found` because `counters_new` it's not a command and you used `$()` – Diego Torres Milano Jun 05 '22 at 00:06

0 Answers0