2

I use a bash shell from command prompt window on my Windows 7 machine. I can do 'history' and get the list of commands in history buffer but when I do '!12' to reexecute command number 12, I get '!12 not found'.

I searched for a solution and found that by default the expansion character is set to '!' but could not find a way to check if it is set to something else.

-MG

4

1 回答 1

3

You can change the history command expansion character using the histchars shell variable. The default is !^# -- the first character is the history expansion character, the second is the quick expansion character (e.g. for ^X^Y^), and the third is the comment character.

You also need to check that !-style history expansion is on. Use set -H to turn it on and set +H to turn it off.

于 2013-03-30T23:19:09.963 回答