Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Mar 082010
 

Count the number of matching lines from grep

Answer:

grep command is useful for searching file's content by a key string, e.g.

# grep foo text.txt

All the lines matching foo will be printed.

However, to only print the number of matching lines, you can use the -c flag

# grep -c foo text.txt
4

There are total 4 lines match the word foo.

Mar 072010
 

Installing Python modules with easy_install

Answer:

Install Python modules cannot be easier with easy_install.

To use easy_install, you can use apt-get to install the "python-setuptools" package

# sudo apt-get install python-setuptools

Then you can use easy_install to install the module you want, e.g. pymongo

# sudo easy_install pymongo