Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigating to the earliest/latest command in history when you're in the middle of your history

Say I am in a bash terminal and have a large history of commands. I pressed the up arrow a whole bunch of times and am in the "middle" of the history. I want to now navigate to the first or the last command in my history quickly (without holding down the up or the down arrow for a long time). Is this possible? If so, what is the shortcut key to achieving this?

like image 858
madiyaan damha Avatar asked Oct 21 '10 21:10

madiyaan damha


People also ask

What is the command to look at history?

Open Start. Search for Command Prompt, and click the top result to open the console. Type the following command to view the command history and press Enter: doskey /history.

How do I run a previous command from history?

Another way to get to this search functionality is by typing Ctrl-R to invoke a recursive search of your command history. After typing this, the prompt changes to: (reverse-i-search)`': Now you can start typing a command, and matching commands will be displayed for you to execute by pressing Return or Enter.

How can you scroll through your command history?

After you have typed what you are looking for, use the CTRL-R key combination to scroll backward through the history. Use CTRL-R repeatedly to find every reference to the string you've entered.

What is command line history?

Command history is a feature in many operating system shells, computer algebra programs, and other software that allows the user to recall, edit and rerun previous commands.


1 Answers

Take a look in the man page:

man bash 

Here I copied for you the thing you were looking for:

previous-history (C-p)     Fetch the previous command from the history list, moving back in the list.   next-history (C-n)     Fetch the next command from the history list, moving forward in the list.   beginning-of-history (M-<)     Move to the first line in the history.   end-of-history (M->)     Move to the end of the input history, i.e., the line currently being entered. 
like image 170
kokosing Avatar answered Sep 21 '22 06:09

kokosing