[Shell]Accessing last commands in history

Last update on July 17, 2009 08:00 AM by jak58
Published by jak58

[Shell]Accessing last commands in history






The shell Linux/Unix provide several features saving time.

Thus, it is possible to go back in history with the recent orders navigation arrows by pressing the up arrow.

Moreover there are ways to access commands quickly in the history! By typing exclamation point (!) followed by the first letters of the command, the shell automatically runs the last command starting with those letters:

Either the following history:

system:/home/user$tail /var/log/syslog
system:/home/user$vi /etc/apache/httpd.conf
system:/home/user$/etc/init.d/mysql restart
system:/home/user$apachectl restart
system:/home/user$tail /var/log/apache/error.log


The following command allows you to access the command n-4 in the history(vi /etc/apache/httpd.conf)


!vi


Further application :
!! //The last commant
!23 //The 23th command
!-2 // Execute the last command

!?profil //The last command containing the word "profil"
^13^14^ //Substitution in the last command


The history of command is registered at each end of session under the file:
~/.bash_history

To avoid duplication in this file and history, add the line ~/.bash_profile in the command:

export HISTCONTROL=ignoredups

You can however display the search command function by pressing CTRL+R
Best answers for « Accessing last commands in history » in :
Clearing the history of the Run utility Show Clearing the history of the Run utility Step1 Step2 Searching in the registry editor Searching in through the registry tree To delete all entries in the history of the "Run", you just have to edit the registry and remove some...
Accessing to recent commands from the history ShowAccessing to recent commands from the history The Linux / Unix shell is full of features allowing you to save time and making your life easier. Using the navigation arrows ( up arrow key). it is possible to go through history tof the...
Command prompts for Windows ShowCommand prompts for Windows Some of these command below can cause harmful an undesirable functions, leading to the formatting of your hard disk and data loss, while others will not run under Windows XP. As for Windows Vista the Run Tab is not...
Access the hidden Administrator Account in Windows Vista ShowAccess the hidden Administrator Account in Windows Vista Why has the Administrator account been disabled in Vista? How to activate the Administrator Account Solution 1: Through User Account Control Solution 2: With Command Prompt Solution...
Using Telnet ShowIntroduction to Telnet Telnet is a protocol for emulating a remote terminal, which means that it can be used to run commands entered on a keyboard at a remote machine. The tool Telnet is an implementation of the Telnet protocol, which means that it...
UNIX Commands ShowTable of the main UNIX commands Unix Commands Description Options ls lists the content of a directory -a Displays all files, including hidden files -I Displays a...
Random access memory (RAM or PC memory) ShowTypes of random access memory There are generally two broad categories of random access memory: DRAM memories (Dynamic Random Access Module), which are inexpensive. They are used essentially for the computer's main memory SRAM memories (Static...