문제

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