Tuesday, December 4, 2012

Windows Username in JAVA

This is a simple code to retrieve windows username in JAVA.

public class getWindowUsername {
    public static final void main( String args[] ) {
      String userName = System.getProperty("user.name");
      System.out.println("Window's Username: "+userName);

Monday, December 3, 2012

List files contains 'WORD' word

In Linux, grep command can be used to find files that contain specific word.

Change directory first to location where files are located.
Use following command to get file list

grep -l WORD *.*

Above command will list all files that contains word "WORD".

To get word location in file remove -l flag.