To highlight and see a specific command that was executed in the Linux terminal, we can use the history
command followed by the |
operator (pipe operator), then the grep
command and, the name of the command we need to see highlighted.
# Highlight and see specific command was executed
history | grep <YOUR_COMMAND_TO_HIGHLIGHT>
For example, let's say we need to highlight and see whether the ls
command was executed in the terminal. To do that we can use the history
and the grep
command like this,
# Highlight and see specific command was executed
history | grep ls
The above commands do the following operations:
- First, The
history
command will get all the commands executed in the terminal. - The output of the
history
command is then piped into thegrep
command and then thegrep
command will highlight the allls
commands which were executed.
The output of the above command may look like this,
See the execution of the above command live in repl.it.
That's all 😃!