A
A
Albert2019-10-26 08:25:09
linux
Albert, 2019-10-26 08:25:09

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.pysudo apt upgradeand 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

4 answer(s)
L
longclaps, 2019-10-26
@longclaps

There is such a file, ~/.bash_history , write a script that combs it when loading - and you will be more or less good.

R
Ruslan Fedoseev, 2019-10-26
@martin74ua

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.

S
Sergey c0re, 2019-10-26
@erge

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

Андрей, 2019-10-26
@VladimirAndreev

Может, в ~/.bashrc прописать алиасы на самые нужные команды и их использовать?
Чтобы заработало, нужно выполнить
source ~/.bashrc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question