Live Chat!

Exclusive Grep

          0 votos

November 7th, 2006 liewsheng

When you have ‘grep’ some keyword:
grep “keyword” filename
tons of lines and dozen of words you don’t want may show on the screen. What can you for this? Of cause is filter out the unwanted word ;p it is easy to ‘exclusive’ the unwanted keyword:
grep “keyword” filename | grep -v “non-keyword”
the ‘-v’ here will display [...]

Posted in Text Manipulation, grep | Hits: 7305 | 7 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: 20353 | 1 Comment »

grep with color

          0 votos

October 5th, 2006 mysurface

Nowadays most of the time, terminal support coloring. For example when you list the files in a directory, the file listed with display with different color, which indicate different type of files.
Grep too, support color, you can do this
grep –color “printf” src
grep will list all lines from files in src directory which have keyword “printf” [...]

Posted in Misc, Text Manipulation, grep | Hits: 1695 | 5 Comments »

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: 9734 | 3 Comments »

query using debian packaging manager

          0 votos

September 24th, 2006 mysurface

I am here to show you two examples of using dpkg to query package info.
To know what deb package is installed, you can do this
dpkg -l
Usually we do this with grep, to filter only info that we are interested in, let say i want to know the packages consist of keyword gcc.
dpkg -l | grep [...]

Posted in Admin, backquote, dpkg, grep, pipeline, which | Hits: 8912 | 2 Comments »

searching files with locate, find and grep

* * * * * 1 votos

September 18th, 2006 mysurface

I am here to show you 3 ways to search for files in linux.
locate is the most easilest way to search for files.
To search for a file with filename hello.c
locate hello.c
You need to update the database in order to search for files completely, like this
updatedb
For security purpose, sometimes, it is not recommended to updatedb using [...]

Posted in Common, Text Manipulation, find, grep, locate | Hits: 8181 | No Comments »

invert match with grep

          0 votos

September 16th, 2006 mysurface

Usually if you want to search for string with specific keyword, you use grep.
cat /etc/passwd | grep root
This will list all lines with keyword “root” .
What if you want to list all entry without keyword “root” ?
cat /etc/passwd | grep -v root
Related Postsgrep multiple keywords, AND not ORThis morning, I asked to analyze log files [...]

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

grep for a few lines

          0 votos

September 15th, 2006 mysurface

One of the useful option for grep, when you find the keyword you are searching, instead of return a particular line that contains the keyword, it allows you to specified how many lines to return by specified -A option.
Let say I want to return 5 lines when i found “main” at hello.c.
grep -A 5 main [...]

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

get to know which command use to trigger the GUI program

          0 votos

September 9th, 2006 mysurface

If you are light weight windows manager user which depend on certain desktop such as kde, gnome, sometimes you want to know what is the command that call a particular program that you usually click with your mouse in kde/gnome, so that you can run it in console or trigger with key mapping.
You can get [...]

Posted in X11, grep, pipeline, xprop | Hits: 5615 | No Comments »

grep as a filter for your raw text based data

          0 votos

August 15th, 2006 mysurface

grep is a very useful and simple tools for a unix user to extract info from text based data files, command output, etc. grep always apply together with pipeline to simplified the data output we obtain to form the information which is presentable.
For example, ps aux will shows info about the current running processes. But [...]

Posted in Common, Text Manipulation, cat, grep, pipeline, ps | Hits: 8180 | No Comments »