Live Chat!

sometimes, grep alone is enough to do the task

2 votos Vota!!

April 14th, 2009 mysurface

One thing that makes UNIXes command line so powerful is because of pipelines. Pipelines is a set of processes chained by their standard streams, so that the output of each process (stdout) feeds directly as input (stdin) of the next one. Simple words, pipelines pass the outcomes of a particular command as input to another [...]

Posted in Text Manipulation, grep | Hits: 139737 | 1 Comment »

what is your 10 common linux commands?

4 votos Vota!!

October 27th, 2007 mysurface

Dear command line ninjas, Mr CLI and keyboard pianist:
What is your regular command you use? I am sure you must thinking of ls and cd. Yeah, they are common for every users, but how about the rest of them? I have construct a combos of commands to help you identify your top ten linux command. [...]

Posted in Common, awk, column, grep, head, history, nl, sort | Hits: 40737 | 28 Comments »

How to list just directories

2 votos Vota!!

September 19th, 2007 mysurface

There are no such direct ways to list only directories using the UNIX/ linux famous command ls. Anyway with command combo’s, we can achieve the goal in two ways shown as below.
1. use ls -l with grep
2. use find -type d
( The statement above is WRONG, check out the simple way to list just directories [...]

Posted in Bash, Text Manipulation, column, find, grep, ls | Hits: 42796 | 9 Comments »

What is my Public IP Address?

9 votos Vota!!

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: 57492 | 6 Comments »

grep multiple lines

1 votos Vota!!

August 9th, 2007 mysurface

You can grep multiple lines before or after matching the keywords. Here is a simple tips, that what I discover grep capable of. A is after, B is before.
Let say you have the message.txt shows as below:

Aug 5 02:43:12 zion kernel: [ 0.000000] Zone PFN ranges:
Aug 5 02:43:12 zion kernel: [...]

Posted in Text Manipulation, grep | Hits: 42823 | 8 Comments »

grep multiple keywords, AND not OR

2 votos Vota!!

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: 41879 | 9 Comments »

perform grep and make in vim

0 votos Vota!!

June 15th, 2007 mysurface

We can do grep and make in vim, the advantage of doing that in vim compare to terminal is you can use the result to track the error and warning for make or goto the line and files of the grep results.
How to make in vim?
:make
In order to make, the current directory must contain a [...]

Posted in Text Manipulation, grep, make, vi, vim | Hits: 36213 | 1 Comment »

Sort grep -c results

0 votos Vota!!

April 17th, 2007 toydi

grep -c “TODO:” *.c

foo.c:1
bar.c:0
spam.c:44
egg.c:32
matrix.c:0
grep -c displays the total count of matching lines for each input file, just like above.
Now, to sort the results by total count:
grep -c “TODO:” *.c | sort -nt: -k2

bar.c:0
matrix.c:0
foo.c:1
egg.c:32
spam.c:44
It sorts the list by total count or the 2nd field (-k2) by comparing them as numbers (-n). Don’t forget to [...]

Posted in Text Manipulation, grep, sort | Hits: 26965 | 1 Comment »

Redirect output to multiple processes

0 votos Vota!!

November 8th, 2006 toydi

Since tee can read the standard input, and write to multiple files, we may leverage this feature so that it writes to multiple processes (instead of files).
tee >(process1) >(process2) >(process3) | process4
>( ) (see process substitution) pretends itself as a write-only file. Everything you write into it, will be passed to the command (as standard [...]

Posted in Common, grep, process substitution, tee | Hits: 46449 | 28 Comments »

Matching Whole Word in Grep

1 votos Vota!!

November 7th, 2006 liewsheng

Is “grep” capable to match a whole word? The answer of cause is yes!!
grep -w “keyword” filename
this will only display the line with matching word. Using the file contents in previous example, if this command enter:
grep -w “ates” filename
you will get:
ates, 953645
Related Posts“Number” Manipulation in Grep”grep” will able to display the lines match with [...]

Posted in Text Manipulation, grep | Hits: 13886 | No Comments »