How to highlight and see a specific command that was executed in the Linux terminal?
Published August 12, 2021
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
historycommand will get all the commands executed in the terminal.
- The output of the
historycommand is then piped into the
grepcommand and then the
grepcommand will highlight the all
lscommands 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 😃!