Answer the question
In order to leave comments, you need to log in
How to store only unique commands in ubuntu terminal?
How can I make the ubuntu terminal only store the unique actions (commands) of the user?
I mean strings like python main.py
sudo apt upgrade
and so on.
For example, I want to find the actions that I did the day before yesterday.
I open the terminal and press the "up" arrow on the keyboard (and I can see my commands included in the history).
This is convenient, but there is a lot of repetition, I would like to have only a unique set of actions.
PS: while asking a question, I found a useful feature to look in the history - history | grep.
However, this does not change the essence of the question.
Answer the question
In order to leave comments, you need to log in
There is such a file, ~/.bash_history , write a script that combs it when loading - and you will be more or less good.
man bash
/history
/
/
...
and we come across an interesting piece of documentation
HISTCONTROL
A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespace, lines which begin with a
space character are not saved in the history list. A value of ignoredups causes lines matching the previous history entry to not be saved. A value of
ignoreboth is shorthand for ignorespace and ignoredups. A value of erasedups causes all previous lines matching the current line to be removed from the his-
tory list before that line is saved. Any value not in the above list is ignored. If HISTCONTROL is unset, or does not include a valid value, all lines read
by the shell parser are saved on the history list, subject to the value of HISTIGNORE. The second and subsequent lines of a multi-line compound command are
not tested, and are added to the history regardless of the value of HISTCONTROL.
longclaps or set up history - Ruslan Fedoseev
+ also, a useful thing:
in the console you can press Ctrl + r
an invitation will appear
(reverse-i-search) `':
enter part of the command name or a piece of the parameters of any command that you called before and you will be given the whole command
again pressing Ctrl + r issuing the next matching command
pressing the arrows left to right - exit to the console with the found command, we can correct the call parameters, for example.
pressing enter - accordingly immediately execute
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question