Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why some lines in Bash history become "*"?

Tags:

bash

Why some lines (as below line 509 and 512 ) in Bash history become "*", after I execute reverse-i-search?

507  stty -ixon 508  history 509*  510  echo 10 511  echo 20 512*  513  ls 514  history 515  stty ixon 516  stty -a 517  stty -h 518  man stty 519  history 
like image 272
Boreas320 Avatar asked May 14 '15 13:05

Boreas320


People also ask

What does* mean in Bash history?

The star means the line has been modified.

What is bash history expansion?

History expansion is performed immediately after a complete line is read, before the shell breaks it into words, and is performed on each line individually. Bash attempts to inform the history expansion functions about quoting still in effect from previous lines. History expansion takes place in two parts.

Which command in bash executes the last line in shell history?

!- 1 is the same as !! and executes the last command from the history list, !- 2 second to last, and so on. Another way to search through the command history is by pressing Ctrl-R .

How does Linux history work?

Basic Linux historyThe history command simply provides a list of previously used commands. That's all that is saved in the history file. For bash users, this information all gets stuffed into the . bash_history file; for other shells, it might be just .


2 Answers

The star means the line has been modified. See man history.

Demonstration:

From the terminal prompt use the up-arrow key to display a previous command. Delete the command with the backspace key. Use the down-arrow key to return to the last prompt and enter history The modified line should now be displayed in the history as a line number followed by a star.

like image 94
maggick Avatar answered Sep 24 '22 12:09

maggick


* Asterisk is an indication as well, that the commands were run from a different session. You can check this by opening two terminal windows, running bunch of commands and checking history on both. Asterisk will only appear on the commands the other window executed.

like image 43
user1767754 Avatar answered Sep 25 '22 12:09

user1767754