Search file or log for words or strings

view story

http://www.unix.com – i want to search a log for occurrences of words and i want the result to tell me how many lines in the log contained each word. if i type a command like this: Code: egrep "cat|dog|monkey|bananas|bike" logfile i would like a response like this: Code: cat=3,dog=17,monkey=1,bananas=102,bike=51 the numbers above for each word being searched for denotes the number of lines found in the log that contained those words. OS: linux / sunos language: bash (HowTos)