Live Chat!

what is your 10 common linux commands?

* * * * * 2 votos

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: 21914 | 21 Comments »

How to list just directories

* * *     2 votos

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: 24795 | 8 Comments »

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

grep multiple lines

* * * *   1 votos

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: 25710 | 3 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: 24931 | 8 Comments »

perform grep and make in vim

          0 votos

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: 21966 | 1 Comment »

Sort grep -c results

          0 votos

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: 14529 | No Comments »

Redirect output to multiple processes

          0 votos

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: 18592 | 26 Comments »

Matching Whole Word in Grep

          0 votos

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: 5397 | No Comments »

“Number” Manipulation in Grep

* * *     3 votos

November 7th, 2006 liewsheng

“grep” will able to display the lines match with keyword or non-keyword (using option “-v”), but you may want to continue to display another few lines after/before the matched keyword:
grep -A N “keyword” filename
this will continue display N lines after the matching line. To display the N lines before matching line :
grep -B N “keyword” [...]

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