Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've been using `history -a`, but what do `history -c` and `history -r` do?

It looks like it clears your shell's history, and then re-populates it from the .bash_history file?



   history -a  # append history lines from this session to the history file.
   
   #History file may contain history from other terminals not in this one so:

   history -c # clear [in-memory] history list deleting all of the entries.
   history -r # read the history file and append the contents to the history list instead.
I've heard that -n can be problematic which is why -c then -r is used.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: