Search Unix Commands/Scripts


  Help us in improving the repository. Add new commands/scripts through 'Submit Commands/Scripts ' link.





Unix Commands/Scripts for '#Grep' - 12 Commands/Scripts found

 Sample 1. Finding any of the multiple texts strings in file

egrep 'Error|Exception|Debug' logfile.txt

   Like      Feedback     egrep   grep log  grep


 Sample 2. Tail log to see only lines containing an error / exception in last 5000 lines

tail -5000 /opt/WebSphere6/AppServer/profiles/Viva/logs/VivaWebClusterMemberPsc9800/SystemOut.log | grep -i "FileNotFoundException"

   Like      Feedback     tail  tail logs  check logs for errors  grep  grep -i  grep ignore case


 Sample 3. Get lines containing any of the multiple errors / exceptions in running logs

tail -f /opt/WebSphere/AppServer/profiles/application/logs/SystemOut.log | egrep "(WSWS3713E|WSWS3734W|WSVR0605W|javax.net.ssl.SSLHandshakeException|ThreadMonitor)"

   Like      Feedback     grep  grep logs  tail  tail -f  egrep


 Sample 4. Count a particular word ( error ) in a file

grep -c "Error" logfile.txt

   Like      Feedback     grep   grep log  grep -c


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
 Sample 5. count number of error / exception occurences in a file.

sed -n '/ERROR/,/EST/p' /opt/WebSphere/AppServer/profiles/application/logs/SystemOut.log | grep "LogicBlockSetupException" | wc -l

   Like      Feedback     sed  grep  word count  wc  wc -l


 Sample 6. Finding relevant word and excluding irrelevant word

grep xception logfile.txt | grep -v ERROR

   Like      Feedback     grep   grep log  grep -v


 Sample 7. Finding text within .gz (zipped) file without unzipping them

zgrep -i Error *.gz

   Like      Feedback     grep  zgrep  zgrep -i  grep within zipped file


 Sample 8. find occurences of a particular error in last n days

find /opt/WebSphere/AppServer/profiles/application/logs/ -iname "SystemOut*" -mtime -7 -exec zgrep "FileNotFoundException" {} ; >> logAnalysis.txt

   Like      Feedback     find  zgrep  -iname  0mtime  >>


 Sample 9. Get all Errors in a log file for last n days in a seperate error file

find /LogFilesfolder/ -iname "SystemOut*" -mtime -7 -exec zgrep "| ERROR |" {} ; >> logReport.txt

   Like      Feedback     find  -iname  -mtime  zgrep  find errors in log file


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
 Sample 10. Display the file names that matches the given pattern

grep -l ERROR *.log

   Like      Feedback     grep


 Sample 11. Get Error Snippets in running logs

tail -f /opt/WebSphere/AppServer/profiles/application/logs/SystemOut.log | sed -n '/ERROR/,/EST/p'

   Like      Feedback     grep  grep logs  tail  tail -f  sed  sed -n


 Sample 12. Count words in a File

grep "Text" file.txt | wc -l

   Like      Feedback     count words in a file  grep  wc  word count



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner