Speedup sed search and replace
Answer:
If you have a very large file, sometimes you can speed up sed by using the following method:
Original method:
# sed 's/foo/bar/g' filename
Optimized method:
# sed '/foo/ s/foo/bar/g' filename
The second method is faster since substitution is only performed when the search string is found.
Quickly open to file and position a cursor with vim
Answer:
To open a file and automatically move the cursor to a particular line number
# vi +80 test.txt
The vim will move the cursor to line 80 when opened the file.
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.
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
How to pronounce Gnome?
Answer:
The official pronunciation is "ga-nome", but most people say "nome"