HISTSIZE and HISTFILESIZE


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers HISTSIZE and HISTFILESIZE
# 1  
Old 06-25-2012
HISTSIZE and HISTFILESIZE

Hi

Whats the exact difference between HISTSIZE and HISTFILESIZE in bash shell?

Thanks
# 2  
Old 06-25-2012
Code:
 
man bash

Code:
 
     HISTFILE
          The name of the file in which command history is  saved
          (see    HISTORY   below).    The   default   value   is
          ~/.bash_history.  If unset, the command history is  not
          saved when an interactive shell exits.
     HISTFILESIZE
          The maximum number of lines contained  in  the  history
          file.  When this variable is assigned a value, the his-
          tory file is truncated, if necessary, by  removing  the
          oldest  entries, to contain no more than that number of
          lines.  The default value is 500.  The history file  is
          also  truncated  to  this size after writing it when an
          interactive shell exits.

# 3  
Old 08-25-2012
Read the question properly

Dude, you didn't answer the actual question. Try reading it again.

The question was what is the difference between HISTSIZE and HISTFILESIZE.

The OP is right, the bash man page is somewhat confusing, it states:
Code:
HISTFILESIZE
      The maximum number of lines contained in the history file.   When  this  variable  is  assigned  a
      value,  the history file is truncated, if necessary, by removing the oldest entries, to contain no
      more than that number of lines.  The default value is 500.  The history file is also truncated  to
      this size after writing it when an interactive shell exits.
...
HISTSIZE
      The  number of commands to remember in the command history (see HISTORY below).  The default value
      is 500.

which sound kinda similar.

pandeesh - the answer is you can use either if you want to increase the number of items in your history; however HISTFILESIZE refers specifically to the actual history file itself (e.g. ~/.bash_history) which is written when the shell exits. HISTSIZE refers specifically to history as saved in memory.
These 2 Users Gave Thanks to King Clarity For This Post:
# 4  
Old 08-25-2012
Code:
HISTSIZE     --> number of lines of command to store in history "list" (memory)
HISTFILESIZE --> number of lines of command to store in history "file"

The history "file" is not updated as you type the commands. The commands get stored in a "list" separately (accessed by the history command). The number of these stored commands is controlled by HISTSIZE value. When the shell (interactive) exits, the last $HISTSIZE lines are copied/appended to $HISTFILE from that "list". If HISTFILESIZE is set, then after this operation, it is ensured that only $HISTFILESIZE lines (latest) exist in $HISTFILE. And when the shell starts, the "list" is initialized from $HISTFILE upto a maximum of $HISTSIZE commands.
# 5  
Old 08-29-2012
@King_Clarity
Please do not respond to 2-month old posts unless you have something new to add. The O/P @pandeesh is known to rarely read and understand man pages.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

HISTSIZE environment variable problem

Hi All, I am connecting to a sun solaris 5.9 unix (korn shell) server using the x terminal. There is some problem with the HISTORY File where the HISTSIZE env variable is not working. Although the HISTSIZE is set to 20 already but the HISTORY file keep increasing and exceeded the size. There... (5 Replies)
Discussion started by: Kenneth2006
5 Replies
Login or Register to Ask a Question