sometimes, grep alone is enough to do the task

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 grep, Text Manipulation | Hits: 213565 | 3 Comments »

what is your 10 common linux commands?

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 […]

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

How to list just directories

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 […]

Posted in Bash, column, find, grep, ls, Text Manipulation | Hits: 144706 | 15 Comments »

What is my Public IP Address?

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. – the chicken looks so […]

Posted in curl, egrep, grep, Misc, Text Manipulation, wget | Hits: 148520 | 20 Comments »

grep multiple lines

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: [ 0.000000] […]

Posted in grep, Text Manipulation | Hits: 159114 | 24 Comments »

grep multiple keywords, AND not OR

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 egrep, grep, Text Manipulation | Hits: 134587 | 21 Comments »

perform grep and make in vim

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 […]

Posted in grep, make, Text Manipulation, vi, vim | Hits: 102992 | 3 Comments »

Sort grep -c results

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 […]

Posted in grep, sort, Text Manipulation | Hits: 88346 | 2 Comments »

Redirect output to multiple processes

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 […]

Posted in Common, grep, process substitution, tee | Hits: 200317 | 61 Comments »

Matching Whole Word in Grep

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 […]

Posted in grep, Text Manipulation | Hits: 91028 | 2 Comments »