Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Apr 232010
 

How to avoid command being saved to shell history

Answer:

Firstly, you need to set the Bash shell environment variable to tell the shell to ignore the history if the command is starting with a particular character, e.g. a space in our case below.

# export HISTIGNORE="&:[ ]*"

Then, type the command start with a space

# who

And verify using the history command

# history

Mar 292010
 

Repeat previous command in Bash

Answer:

It is easy to type !! when you want to repeat the previous executed command in Bash

# ls -l /var/log/messages
-rw-r----- 1 syslog adm 330 Mar 29 17:17 /var/log/messages

# !!
ls -l /var/log/messages
-rw-r----- 1 syslog adm 330 Mar 29 17:17 /var/log/messages