Penguin
Annotated edit history of BashHistory version 3, including all changes. View license author blame.
Rev Author # Line
1 BenStaz 1 !!Bash History
2
3 You can see which file bash history is being written to by doing:
4
5 *echo "$HISTFILE"
6
2 BenStaz 7 As you probably already know, you can use the up and down arrow keys to cycle through the bash history, but you can also search it!
8
3 BenStaz 9 To do so, press ''C-r''. You will be prompted for a search term. Start typing in part of the command you are trying to find. For example : if it was a [mplayer] command, start typing ''mplayer''. You will notice that as you type, the most recent command from the bash history matching what you have typed will be displayed to you. When you see the one you are after simply press enter to execute that command.
1 BenStaz 10
11 !List Bash History Commands
12
13 Use the ''fc'' command with the -l switch:
14
15 *fc -l -5
16
17 Will list the last 5 commands in the bash history file.
18
19 *fc -l 5 10
20
21 Will list commands 5 to 10 in the bash history file.
22
23 *fc -l mplayer mplayer
24
25 Will list the last mplayer command.
26
27 !Command Substitution
28
29 <verbatim>
30 ! Begin a history substitution.
31 !! Previous command.
32 !N Command number N in history list.
33 !-N Nth command back from current command.
34 !string Most recent command that starts with string.
35 !?string? Most recent command that contains string.
36 !?string?% Most recent command argument that contains string.
37 !$ Last argument of previous command.
38 !# The current command up to this point.
39 !!string Previous command, then append string.
40 !N string Command N, then append string.
41 </verbatim>