Linux – Finding Text in Log Files – Day 1


Don’t really spend much time in the Linux World.

But, there are many Application Servers that sit on Linux Servers and rely on SQL Server on Windows.


Log Files

When error occurs a good Application Server write these errors in Log Files.

After a while needs develop to trend the type of DB Connectivity and more serious hard errors.


Sample Log Files

As we discussed in a recent post, we copied over SQL Server Error Log files over to Linux.


Text Search


Let us use grep to perform simple Text Searches.


Look for Text Matching Manufacturer


grep -w -i -l -n  "Manufacturer" ERRORLOG


  1. No matches



Attempted Workarounds

We tried the following workarounds

  1. Worked
    • Created a much simple text file and was able to grep against it
  2. Did Not Help
    • Modified copy over mode to binary and back to text
    • Command Issued
      • cat ERRORLOG | grep -i “manufacturer”




cat ERRORLOG | tr -d '\000' | grep -i "manufacturer"


Why does it work

  1. Cat
    • Outputs a file’s content
  2. tr – stands for translate
    • tr -d ‘\000’
      • -d means delete
      • \000 means null character


What makes grep consider a file to be binary?

When you are top 13% on stackexchange, you are one of the Big Boys and Girls.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s