Live Chat!

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

Run multiple commands consequently

          0 votos

October 3rd, 2006 mysurface

By specified terminator ( ; ) like in C/C++ programming, you can run multiple commands consequently. We usually want to do this when we want to compile and install source code for certain packages.
./configure;make;make install
Bash first execute the configure, then make , consequently will install the package. But bare in mind, bash have no intelligent, [...]

Posted in Symbol, du, read, terminator, while | Hits: 15620 | 3 Comments »

easily extract a column of data from multiple columns

          0 votos

October 2nd, 2006 mysurface

To extract a column of data from multiple column, we can use cut. Usually cut use to extract value from huge trace file or data file such as /etc/passwd.
To extract all available user name from /etc/passwd, you can do this
cut -d”:” -f1 /etc/passwd
Cut extract value line by line, to put all into 1 line, you [...]

Posted in Misc, Text Manipulation, cut, pipeline, xargs | Hits: 16026 | 2 Comments »

xargs use stardard output as parameter for another command

          0 votos

October 2nd, 2006 mysurface

xargs is a command line of findutils package. It is not so common for new user, but it is a very useful tools, let me pick an example to show the usage. Bare in mind, xargs is a kind of combo command use together with other command through pipeline.
I have a list of links to [...]

Posted in Text Manipulation, cat, pipeline, wget, xargs | Hits: 15038 | 10 Comments »

Redirect stderr to stdout

* * * * ½ 2 votos

October 1st, 2006 toydi

Very simple, just remember:

1 = stdout
2 = stderr

In python, its
unittest
module loves to dump test results to stderr (rather than stdout). In order to pipe the results to
less
, you may need to redirect stderr to stdout:
python eggtest.py 2>&1 | less

To redirect stderr into a file:
python eggtest.py 2> result.txt
To redirect both stdout and stderr into a [...]

Posted in pipeline, stderr, stdout | Hits: 17073 | 1 Comment »

generate and print a sequence of number

          0 votos

September 28th, 2006 mysurface

To generate a sequence of number we can use seq
seq 1 10
With this it prints 1 to 10 line by line, because by default separator is new line, anyway you can check, do this
seq -s” ” 1 10
Doing this it change new line to a single blank space.
But that is the usage of the this [...]

Posted in Misc, Text Manipulation, backquote, cat, pipeline, seq, wc | Hits: 13067 | 1 Comment »

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: 8913 | 2 Comments »

check the file type

          0 votos

September 23rd, 2006 mysurface

A command file is a good tool to help you determine what file type of a file. To check for a file type simply do this
file filename
Let say i want to check the file type of command line update-rc.d, i can do this
file `which update-rc.d`
output:
/usr/sbin/update-rc.d: perl script text executable
Uses which to returns the full path [...]

Posted in Common, backquote, file, which | Hits: 6630 | 1 Comment »

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

Command line calculator, bc

* * * * * 1 votos

September 4th, 2006 mysurface

How to do calculation if I only have command line? If you have BC you can, and you can do a very complicated calculation. To perform calculation, you can type bc and start to type your question, or passing question through pipeline, such as
echo “56.8 + 77.7″ | bc
Let say you want to convert decimal [...]

Posted in Calculation, bc, pipeline | Hits: 11435 | 7 Comments »