Code Snippet

Just another Code Snippet site

Random Post :




Generate Test Data

Generate User profile (Web or API) :
http://randomuser.me/

Generate full data file :
http://www.generatedata.com/

[Yana] Linux Client

http://forum.idleman.fr/discussion/336/yana-client-for-linux

[Find] How-to

find . -name "*.java" -exec grep -ni <pattern_to_find> /dev/null {} \;

List only directories, max 2 nodes down that have “net” in the name

find /proc -type d -maxdepth 2 -iname '*net*'

Find all *.c and *.h files starting from the current “.” position.

find . \( -iname '*.c'  -o -iname '*.h' \) -print

Find all, but skip what’s in “/CVS” and “/junk”. Start from “/work”

find /work \( -iregex '.*/CVS'  -o -iregex '.*/junk' \)  -prune -o -print

Note -regex and -iregex work on the directory as well, which means
you must consider the “./” that comes before all listings.

Here is another example. Find all files except what is under the CVS, including
CVS listings. Also exclude “#” and “~”.

find . -regex '.*' ! \( -regex '.*CVS.*'  -o -regex '.*[#|~].*' \)

Find a *.c file, then run grep on it looking for “stdio.h”

find . -iname '*.c' -exec grep -H 'stdio.h' {} \;

sample output –> ./prog1.c:#include
./test.c:#include

Search a string in JAR file :

zipgrep "STRING_TO_FIND" file.jar

Search a string in multiple JAR files :

find JAR_FOLDER -name "*.jar" -exec zipgrep "STRING_TO_FIND" '{}' \;

Previous Posts Next posts