Operating System - HP-UX
1834116 Members
2370 Online
110064 Solutions
New Discussion

Oops! I edited my .history file, now it doesnt work

 
Travis Rebok
Advisor

Oops! I edited my .history file, now it doesnt work

I edited my shell command history file (.history). Now when I try to pull up my old commands from the command line all I get is junk. Basically it looks like all of the commands string together. Obviously I screwed the file up when I edited it. Is there a way that I can fix the file so that I will be able to retrieve my old commands again? I'm on On HP10.20
7 REPLIES 7
melvyn burnard
Honored Contributor

Re: Oops! I edited my .history file, now it doesnt work

recover from a backup, if ther e is a recent one.
Otherwise, if you know what and where you edited, try un-editing it.
Ohterwise, you will have to remove it and start again.
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
steven Burgess_2
Honored Contributor

Re: Oops! I edited my .history file, now it doesnt work

Hi

What happens if you try

fc -l

Regards

Steve
take your time and think things through
S.K. Chan
Honored Contributor

Re: Oops! I edited my .history file, now it doesnt work

I don't think so. You'll have to trim it or "zeroed" it. To trim it you have to know roughly where in the file is was broken, for example simply doing ..
$ tail -50 .sh_history>.sh_history.good
==> Anything above the last 50 lines are probably "bad".
$ mv .sh_history.good .sh_history
Zeroing it is the cleaner choice here. Of course if you have a recent backup, it'll solve your problem.

Martin Johnson
Honored Contributor

Re: Oops! I edited my .history file, now it doesnt work

" > .sh_history" should clear things up.


HTH
Marty
Martin Johnson
Honored Contributor

Re: Oops! I edited my .history file, now it doesnt work

" > .sh_history" should clear things up.

HTH
Marty
John Poff
Honored Contributor

Re: Oops! I edited my .history file, now it doesnt work

Hi,

When I just want to look at my shell history file, I do this:

strings .sh_history | more

The 'strings' command helps because sometimes there are some binary characters in the history file. You can also pipe it to a file if you need to.

The real question is, why were you editing your history file? What did you do that you don't want them to find out about? ;)

JP
Martin Johnson
Honored Contributor

Re: Oops! I edited my .history file, now it doesnt work

Sorry for the double posts - having problems with timeouts.

:-(
Marty