How to edit the .sh_history file?

How to edit the .sh_history file?

am 09.01.2007 15:53:10 von CesarDBA

Hello All,

I did a mistake and edit the .sh_history ksh file. Now the history file
is useless. Two questions:
1) is it possible edit directly the .sh_history file as we can for
..bash_history file, using an editor?
2) is it possible recover a useless .sh_history file after we edit it
by mistake?

Any help would be appreciate.

Best Regards,
Cesar

Re: How to edit the .sh_history file?

am 10.01.2007 18:04:13 von Janis Papanagnou

CesarDBA wrote:
> Hello All,
>
> I did a mistake and edit the .sh_history ksh file.

Usually you just search in the history file (using vi or emacs editing
modes) or add to the history file by committing any changes done in one
of the editor modes or by issuing a print -s command.

> Now the history file
> is useless. Two questions:
> 1) is it possible edit directly the .sh_history file as we can for
> .bash_history file, using an editor?

In principle I would say that it is possible to edit that file with some
editor[*], but as a practical approach I would negate that question.

[*] It seems that the commands are just separated by NULL charaters.

> 2) is it possible recover a useless .sh_history file after we edit it
> by mistake?

A recover is not possible if you haven't made backups. But if the file is
not completely "useless" you may rebuild a new history file; extract the
text information using the 'strings' command and add the resulting lines
to a new history file using ksh's 'print -s' command.

Janis

>
> Any help would be appreciate.
>
> Best Regards,
> Cesar
>