Grep a part of a log file and convert it into small usable file

Today I had some nice learning due my work. I had a log file of 95MB and I just needed a little part of that file. To get this little part of information. I used my MacBookPro instead of my Windows 7 laptop.
The windows 7 machine had issues to open the txt file of 95 MB while the mac os x lion didn’t had this issue.
I explain how to grep the little parts of a big file of 95MB.
The file in the screen was 95MB use the command:
“tail”

Tail => will show the last 10 (default) lines of the file
When you want to grep a part of the file use the command:
“grep 2011-11-22 SyslogCatchAll-12.txt > test.txt”

This command will save a text file on the location where you want to put it. With the information started on the 2011-11-22 of the date in the file.
When you want to add a part of the file you created already you use the command:
“grep 2011-11-22 SyslogCatchAll-12.txt >> test.txt”
As you see you use the extra >> for adding it to the earlier created file.

When you have done this, it will be easier to send by mail or open on a system which couldn’t handle the 95MB file.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.