سؤال

Have you ever used a command in the Terminal, but then later forgot what you typed, and wished there was some way that you could view the last used commands?

هل كانت مفيدة؟

المحلول

There are many ways to search through your command history. Here are 3:

  1. use the up and down arrows on your keyboard when at the command prompt.
  2. use the history command.
  3. Simply press : Control + R when at the command prompt.

E.g : Control + R , then write php

enter image description here

نصائح أخرى

I often use bash-builtin command "history" to search for a certain command, e.g. to get the last sudo command type:

history | grep sudo | tail -n 1

gives the last command (with number) with sudo in it. "tail -n 1" gives the last matched line. Then use

!<number>

to execute exactely this command.

!-1

executes the last command, by the way. works well in bash.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top