Operating System - HP-UX
1752812 Members
5841 Online
108789 Solutions
New Discussion юеВ

Re: How can I make HISTSIZE work?

 
SOLVED
Go to solution
Rashid Ali
Frequent Advisor

How can I make HISTSIZE work?

I changed HISTSIZE to 50 but when I run the command "history", it only shows 15 lines, why?
When I run "wc -l /.sh_history", it shows 60, which is more than HISTSIZE, why?

4 REPLIES 4
Bill Hassell
Honored Contributor
Solution

Re: How can I make HISTSIZE work?

The HISTSIZE variable limits the number of command accessible to the shell. If set to 50, things like ESC / (search) wil be limited to the most recent 50 lines in the HISTFILE. The HISTFILE grows without bounds.

history is not a command but a predefined alias to: fc -l and the man page for sh-posix says that this defaults to -16 (the most recent 16 lines). If you specify a larger history value (ie, history -150) than $HISTSIZE, only the most recent $HISTSIZE lines will be displayed.


Bill Hassell, sysadmin
linuxfan
Honored Contributor

Re: How can I make HISTSIZE work?

Hi Zhang,

The default HISTSIZE is 128, any particular reason you reduced it to 50.

Do a history -50, to list the last 50 commands in your history.

-HTH
Ramesh
They think they know but don't. At least I know I don't know - Socrates
Rashid Ali
Frequent Advisor

Re: How can I make HISTSIZE work?

But if ~/.sh_history file can grow without bounds, how come I never see this file become very big and I never need to trim this file?
Also, I can't trace the commands I keyed in two months ago using ESC, why?
Rashid Ali
Frequent Advisor

Re: How can I make HISTSIZE work?

But if ~/.sh_history file can grow without bounds, how come I never see this file become very big and I never need to trim this file?
Also, By using ESC I can't trace the commands I keyed in two months ago , why?