Recent Notes

Displaying keyword search results 1 - 5
Created by voodoo on June 14, 2011 15:16:30    Last update: June 14, 2011 15:18:18
Count the total number of lines of shell scripts (files ending with sh ): $ find . -type f -name \*.sh | xargs wc -l 2... Count the total number of lines for files under the src directory: find src -type f | xargs wc -l Count the total number of lines for files under the current directory whose path contains src/ : find . -type f -path \*src/\* | xargs wc -l
Created by Dr. Xi on January 14, 2010 00:28:27    Last update: March 30, 2011 15:37:44
A task that a Java developer does so frequently is to find out where a certain class can be found - to resolve compilation errors, classpath issues, or version conflicts of the same class introduced by multiple class loaders. A long while back I wrote a simple Perl script to perform the task. Later I was informed that there are Swing based Jar Browser and Jars Browser . Then, there are a couple of shell one-liners: # one liner 1 find -name "*.jar" -print0 | xarg... But all of them share the same problem: if a class is in a jar nested in another jar, it cannot be found. Such is the case for a class inside a jar under the WEB-INF/lib directory of a...
Created by Dr. Xi on May 05, 2009 19:59:21    Last update: May 05, 2009 19:59:21
Delete a single file: >>> import os >>> file = 'myfile' >>> os.rem... Delete a directory and contents: >>> import shutil >>> dir(shutil) ['Error', ...
Created by Dr. Xi on December 12, 2007 20:30:01    Last update: December 12, 2007 20:32:23
This is a script to tail a log file through the web browser. It uses AJAX, apache web server, mod_python, UNIX utilities tail (requires the --lines switch) and wc . The log file may reside on the web server or any other host accessible from the web server through SSH. Although it's written in python, it should be easy to port to other languages such as Perl. Apache httpd.conf : LoadModule python_module modules/mod_python.so ... Python script: import time, os from os.path import basename ...
Created by Dr. Xi on May 01, 2007 02:52:21    Last update: May 01, 2007 02:52:21
To make a tar file out of all the Java sources under ./path/to/directory/: find ./path/to/directory/ -name '*.java' | tar...