In bash I am often checking the value of a variable, is it OK that it do it this way ? Is there a better way?
Example:
if [ "`echo ${file} | grep -vE '(Trash|home)'`" ] ;then
Which is checking that the variable file does NOT contain the words Trash or home, if it does not then do something. The point is that I'm using echo and grep, probably wasteful I assume.
Another example:
if [ "`less ${TEMPQUERY} | grep 'http'`" ] ;then
Which is checking a file for the string http, if it is in the file, do something.
I guess I'm just wondering what other people do and if there is some strong reason why I should not be coding things in such a way. Anyway, Thank you in advance for you time.