Unix history commands for Java developer productivity
Unix for software developers
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.
- Use the up arrow to view the previous command and press enter to execute it.
- Type !! and press enter from the command line to execute the last command again
- Type !-1 and press enter from the command line to execute the last command !-2 for command before the last and so on.
- Type history followed by enter, which prints a list of last few commands, and then !25 to execute a particular command
- Press Control+P will display the previous command, press enter to execute it.
- 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: UNIX
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home