How to assign the result of
grep -c \"some text\" /tmp/somePath
into variable so I can echo it.
#!/bin/bash some_var = grep -c
To assign the output of a command, use var=$(cmd) (as shellcheck automatically tells you if you paste your script there).
var=$(cmd)
#!/bin/bash some_var=$(grep -c "some text" /tmp/somePath) echo "var value is: ${some_var}"