Skip to content

Instantly share code, notes, and snippets.

@tamboer
Last active December 16, 2015 16:58
Show Gist options
  • Select an option

  • Save tamboer/5466554 to your computer and use it in GitHub Desktop.

Select an option

Save tamboer/5466554 to your computer and use it in GitHub Desktop.
general bash
HISTORY ************************************
To view your history in a editor (to save for later), just type:
history -w ~/history.txt
vim ~/history.txt
export HISTTIMEFORMAT="%F %T "
export HISTTIMEFORMAT='%F %T '
What history -w ~/history.txt does is save the history to a file named history.txt on your home folder (cd ~/). The next command opens up the file for viewing in vim.
You can search through your bash_history by piping your history file into grep like so:
history | grep "search term here"
Execute previous command that starts with a specific word
Type ! followed by the starting few letters of the command that you would like to re-execute. In the following example, typing !ps and enter, executed the previous command starting with ps, which is ‘ps aux | grep yp’.
# !ps
ps aux | grep yp
root 16947 0.0 0.1 36516 1264 ? Sl 13:10 0:00 ypbind
root 17503 0.0 0.0 4124 740 pts/0 S+ 19:19 0:00 grep yp
MOUNT ************************************
sudo mount -t vboxsf WIL /home/user/foldername
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment