bash - Linux Shell .sh, Search Database -


i'm quite new shell bash scripts , hitting wall command first search database , report on entries not correct.

the database should holding entry a,b,c only way can find use, if shell report using x, y.

the problem x, y keep changing.

here's example of have currently.


mailaddr="me@yahoo.com"  # database table entry x , add txt file  find /var/lib/mysql -type f -name '*configuration.myd' -print0 | xargs -0 grep -il 'x' > /root/output_search_results1.txt  # database table entry y , add txt file  find /var/lib/mysql -type f -name '*configuration.myd' -print0 | xargs -0 grep -il 'y' > /root/output_search_results2.txt  # if x file populated email it.  if [ -s /root/example_search_results1.txt ]         mutt -s "which database list example x" $mailaddr < /root/example_search_results1.txt         rm -f /root/example_search_results1.txt  fi  # if y file populated email it.  if [ -s /root/example_search_results2.txt ]         mutt -s "which database list example y" $mailaddr < /root/example_search_results2.txt         rm -f /root/example_search_results2.txt  fi 

problem: x , y changing, ideally want script report if entry not equal a, b or c (which fixed) , output txt emailed me.

i hope can help

have great day.

i think looking "-v" option grep.

from grep man page :

-v, --invert-match invert sense of matching, select non-matching lines. 

so have change grep command :

grep -il -v 'a' -v 'b' -v 'c' 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -