Google

Jun 12, 2014

Unix history commands for Java developer productivity

Unix for software developers

1.Top 17 Unix commands Java developers use frequently 2.History commands 3.Shell scripting 4. Reading from a file
5.Purging older files 6.Splitting and archiving files 7.Emulator, SSH client 8.Unix commands for developers 9.Unix basic interview Q&A

When you are using Linux/Unix command line frequently, using the history effectively can be a major productivity boost. You can accomplish things with less typing. For example, you will be typing lots of commands like

ls -ltr
cd /tmp/user
pwd
cd /tmp/usr

and so on. There are 6 ways to repeat your previous commands quickly without having to type a lot.

  1. Use the up arrow to view the previous command and press enter to execute it.
  2. Type !! and press enter from the command line to execute the last command again
  3. Type !-1 and press enter from the command line  to execute the last command !-2 for command before the last and so on.
  4. Type history followed by enter, which prints a list of last few commands, and then !25 to execute a particular command
  5. Press Control+P will display the previous command, press enter to execute it.
  6. Press Control + R, and then search for the command or arguments typed. This the most useful one.


$history | more

   71  ls -ltr
   72  ls -ltr
   73  ls -ltr
   74  ls -ltr
   75  pwd
   76  pwd
   77  I-2
   78  pwd
   79  ls -ltr
   80  pwd
   81  pwd
   82  pwd
   83  ls -ltr
   84  hsitory | more
   85  history | more

 

To execute the command  pwd again, you can do

 !71
 

Now, what if you want to execute a previous command that starts with certain letters

 !p
 

to execute the pwd command again. The most useful command  of all is

Control+P type "<search text>"

 

 $ cd test15/myAppProperties/
 $ ls -ltr
 $ cd /opt/tmp
 $ CONTROL+Rjb and type 
 $(reverse-i-search)`jbTest15': cd test15/myAppProperties/



This a contextual search of your command history. As you type the search text, the display changes. The most powerful, and useful.

By default, history is stored in ~/.bash_history and ~/.sh_history files. You can list the hidden files with






 
$ cd ~
$ ls -a


~ is the home directory.

You can clear all the previous history with

 
$ history -c


You can do a lot more, but for Java developers, this is a good start.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home