Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Bash keeps a history in .bash_history. If you delete the contents in .bash_history, the history is not reset until you reboot. Is there a command whereby the history can be reset without a reboot?
To explain better what I want to do: When you hit the up button to get back to a formerly entered bash command, the up button will go through the former commands exactly as they were entered, even if a command was entered multiple times. So you have to go back through the same multiple commands again before you arrive at a command that was entered before all those identical commands. What I want is for the command to be registered only once. The .bash_history file actually contains only one of the previously entered commands, but when you are using it, it records multiple entries. Possibly there is a way to stop this multiple command recording.
Bash keeps a history in .bash_history. If you delete the contents in .bash_history, the history is not reset until you reboot. Is there a command whereby the history can be reset without a reboot?
To explain better what I want to do: When you hit the up button to get back to a formerly entered bash command, the up button will go through the former commands exactly as they were entered, even if a command was entered multiple times. So you have to go back through the same multiple commands again before you arrive at a command that was entered before all those identical commands. What I want is for the command to be registered only once. The .bash_history file actually contains only one of the previously entered commands, but when you are using it, it records multiple entries. Possibly there is a way to stop this multiple command recording.
All you do is exit the shell; no need to reboot. Remove .bash_history, exit, then repeat that process. Those things are written to .bash_history when exiting, so if you remove it, you'll be left with what you did in that session. Do it a second time, and you'll be left with just an "exit" in the file.
There's no way (to my knowledge) to prevent the same command from being entered again in that file. You can always just sort/remove duplicates, but seems pointless to me.
There's no way (to my knowledge) to prevent the same command from being entered again in that file.
This is one of the instances where bash (and shells like it) is less then tcsh:
Quote:
The histdup shell variable can be set to not save duplicate events or consecutive duplicate events.
Another is that tcsh has a separate history per shell, it is only automatic saved into a file when the variable savehist is set.
Quote:
the savehist and histfile shell variables can be set to store the history list automatically on logout and restore it on login.
and
Quote:
If the first word of the savehist shell variable is set to a number, at most that many lines are saved. If the second word of savehist is set to `merge', the history list is merged with the existing history file instead of replacing it (if there is one) and sorted by time stamp. Merging is intended for an environment like the X Window System with several shells in simultaneous use. Currently it succeeds only when the shells quit nicely one after another.
(so not if you exit the X session with multiple shells still active, you first have to exit all of the shells separately).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.