Paul - The Programmer

simple & stupid

Use -prune to skip directory while finding file

To ignore a whole directory tree, use -prune rather than checking every files in it.

find \(  -path '<directory-to-skip>'  -o -path '<another-directory-to-skip>'  \)  -prune -o -print

Furthermore, take the file nams in consideration.

find \(  -path '<directory-to-skip>'  -o -path '<another-directory-to-skip>'  \)  -prune -o -name '<file-name-pattern>' -print

This trick really saves me couple of  time when I do a find in a large filesystem.

use regular expression to find files

Say you want to list all the *.py, *.cc and *.h files.

You may use the command below.

find ./ -name '*.cc' -o -name '*.h' -o -name '*.py'

But there is always a better way! So, give a try to the option -regex.

find . -regex '.*\.\(cc\|h\|py\)'

What's the backslashes in expression used for?  Well, the find command uses emacs regular expression syntax!

Possible solution for VNC clipboard doesn't work

Verify the vnc-config is running in the VNC desktop. The nvc-config is required for the clipboard exchange to work.

Change the vim default comments syntax color

The default color for the comment syntax if dark blue. It is not easy to read in a console with black background. Adding the command below to the .vimrc under your home directory can solve the problem.

hi Comment ctermfg=Blue

Of cause, it can use the other colors.  Check with command:

:h syntax

 

 

 

Execute shell command and get the result by python

import os

result = os.popen( 'your command' ).read()

print result
 

 

 os.popen() can invoke the inputted command and grab its output as if it is a file-like object.