Instantly load bash history of one shell into another running shell

$ history -a #in one shell , and $ history -r #in another running shell
By default bash history of a shell is appended (appended on Ubuntu by default: Look for 'shopt -s histappend' in ~/.bashrc) to history file only after that shell exits. Although after having written to the history file, other running shells do *not* inherit that history - only newly launched shells do. This pair of commands alleviate that.
Sample Output
## In shell one ##

$ find -iname "*pdf*"   
<some output>

$ history -a   #You don't need this if you set PROMPT_COMMAND="history -a;$PROMPT_COMMAND" manually or in your ~/.profile or ~/.bashrc

## Switch to another running shell ##

$ #Up arrow does not show the above 'find' command, so do following:
$ history -r
$ find -iname "*pdf*"   #Up arrow now shows the 'find' command

By: b_t
2011-11-05 01:19:30

What Others Think

Australia is at top in the world class assignment help. No one caught them because people are too much fast and can easily sovle assignments and also provide solutions and get expert essay earning. Hope it is better for you to get solution from them.
Antonioomez · 94 weeks and 6 days ago
Accidentally i have come across this website and this website is the best opportunity for learning lots of linux commands. So many students are using this Pasadena Nursing Center place for that. Here in this thread, the command is used to Instantly load bash history of one shell into another running shell. Expecting more such command details from here.
Alyssalauren · 24 weeks and 6 days ago
Building on the success of my first article, I'll be talking about a quick way to get survey history from one shell into another running shell. For example, imagine you want to load the history for one shell into another for use in a reboot script or an automated cron job.
Eerdson · 6 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: