CLI: Command History
From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 06/10/05
- Next message: Fabian Kurz: "Re: wget question"
- Previous message: Amadeus W. M.: "wget question"
- Next in thread: faeychild: "Re: CLI: Command History"
- Reply: faeychild: "Re: CLI: Command History"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 10 Jun 2005 19:43:59 GMT
CLI="Command Line Interface"
One of the most useful features of a modern shell like bash
(although it did 'borrow' this feature from the old C shell), is
the command history.
When you enter commands at the prompt, bash keeps a record of
them, which you can see by entering:
history
See those numbers? If you want to run one of the commands,
enter:
!N
where "N" is the number before it.
To find a command that you made, the best way (unless
it was very recently used) is to use Ctrl-r (^R), and then enter
the first letter or two. If it doesn't show up right away, hit ^R
again until it does, or add the next letter.
When the right command shows up, just hit Enter.
^R is a backwards search through the history file.
^P and ^N move back and forwards through the history file from
wherever you are. (up/down arrows will do the same thing)
^U and/or ^K will clear the prompt.
Needless to say, the history file can get really cluttered,
and fortunately there are ways to keep the clutter down.
(history -c will delete every entry in the history file)
Put these in your ~/.bashrc:
export HISTCONTROL=ignorespace
export HISTIGNORE="ls:cd:&"
and have bash reread the file with:
source ~/.bashrc
HISTCONTROL=ignorespace
That means that any command you run that you
don't want to be recorded in your history file
can just be preceded by a space.
HISTIGNORE="ls:cd:&"
That's a list of patterns (you can use shell
wildcards) that you want to be kept out of
your history file. Short ones that you use
all the time. The "&" means to ignore duplicates.
AC
-- alanconnor AT earthlink DOT net Use your real return address or I'll never know you even tried to mail me. http://tinyurl.com/2t5kp ~
- Next message: Fabian Kurz: "Re: wget question"
- Previous message: Amadeus W. M.: "wget question"
- Next in thread: faeychild: "Re: CLI: Command History"
- Reply: faeychild: "Re: CLI: Command History"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|