Live Chat!

What is my Public IP Address?

* * * ½   6 votos

August 22nd, 2007 mysurface

What is my public IP address? There is a lots of website can provide you the information. What if I wanna grep it for my script? We can use curl and grep for this purpose.
First, lets pick few websites that provide the service to reveal my public IP.
http://www.ipchicken.com/ - the chicken looks so [...]

Posted in Misc, Text Manipulation, curl, egrep, grep, wget | Hits: 34816 | 6 Comments »

grep multiple keywords, AND not OR

* * * * ½ 2 votos

June 21st, 2007 mysurface

This morning, I asked to analyze log files where I need to grep the lines with two keywords, and the post grep based on multiple keywords doesn’t help much.
Refering to the post, where it grep the lines either keyword1 OR keyword2 appears. Where the case I intended to get is different, I need to [...]

Posted in Text Manipulation, egrep, grep | Hits: 24644 | 7 Comments »

square brackets in regular expression

* * * * * 1 votos

October 17th, 2006 mysurface

Previously we have an example on regular expression, but It doesn’t shows the power of square brackets ( [ ] )
Let say you want to search for string fprintf, vprintf and sprintf using grep, usually what you do is
egrep “fprintf|vprintf|sprintf” *.c
You may be ask why don’t just uses the word “printf”? If uses the word [...]

Posted in Regular Expression, Text Manipulation, egrep | Hits: 8342 | 2 Comments »

Regular expression with egrep and ls

* * *     2 votos

October 7th, 2006 mysurface

egrep is actually same as grep -E, it interpret PATTERN as an extended regular expression. Therefore ESCAPE ( \ ) is not needed for certain symbol.
ls is a common tool for listing file that matches the keyword.
Regular expression (RE) is a very important and useful to manipulating strings and text. In this example, I would [...]

Posted in Regular Expression, Symbol, Text Manipulation, egrep, grep, ls | Hits: 15576 | 1 Comment »

grep based on multiple keywords

* * * *   3 votos

September 28th, 2006 mysurface

grep with multiple keywords need some knowledge of regular expression. But that is not difficult, use (OR).
Let say you want to grep “me” and “you” at world.txt, you do
grep “me\|you” world.txt
You need to put ESCAPE STRING ( \ ) for OR ( | ), else it will treat it as a simbol you want to [...]

Posted in Text Manipulation, egrep, grep | Hits: 7343 | 3 Comments »