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

rm complains argument list too long

* * * * * 2 votos

October 20th, 2007 mysurface

There is a limitation of rm command, where you can’t delete a large groups of files with *. For examples,
rm -rf something*
If there are large amount of files initiate with something, rm will fails and complains
/bin/rm: Argument list too long.
The solution is to make use of find, xargs and rm.
find . -name ’something*’ -print0 | [...]

Posted in Common, find, rm, xargs | Hits: 13876 | 5 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: 24177 | 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: 34470 | 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: 25238 | 3 Comments »

extracting substring at bash

* * * * ½ 4 votos

June 28th, 2007 mysurface

Extracting sub string at Bash is very easy, let say you have a phone number 012-4567890 and you just wanna extract 4567890 out, you can do as below.

num=”016-4567890″;
echo ${num:5:7}

5 is the starting point and 7 is the string length for sub string.
Related PostsA Bash Completion TipBash Completion is a powerful CLI magic for bash user, [...]

Posted in Bash, Text Manipulation | Hits: 24827 | 12 Comments »

array and for loop in awk

* * * *   1 votos

June 25th, 2007 mysurface

grep is always a useful tools to help analyze logs. When the logs are managed nicely in rows and columns format, awk will be much more efficient compared to grep. Refers to simple examples of awk here.
Awk support array and for loops. Let say I have IP logs that access to my servers time to [...]

Posted in Text Manipulation, awk | Hits: 21190 | No 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: 24403 | 7 Comments »

Web Authoring with Vim

          0 votos

June 18th, 2007 toydi

In usual editing, to open a file with vim, we run the command:
vim /path/to/file
It is also possible to browse a directory using vim:
vim /path/to/directory/
When we are inside vim, to save a file, we use the :write command, :read to read an existing file into current buffer; or using :tabnew /path/to/file to open a [...]

Posted in Network, Text Manipulation, vim | Hits: 17242 | No 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: 21562 | 1 Comment »