Comentários (5)

1 andreas. comentou às Link permanente

Why don't you just use "history | grep ..."? Or even better: Define an alias, i.e. alias hg='history | grep', and then just type "hg rm" to find all recent "rm" commands. Just make sure that your HISTSIZE is set to a suitable value.

2 brian_s comentou às Link permanente

This posting is geared for searching through history files of other user accounts. For example, if you are trying to find out who/what caused an issue on a server, you could search for all history files on the server using find, and then use this "strings" method to grep for suspect commands to narrow down what happened.

3 frenger comentou às Link permanente

Hi Brian <div>&nbsp;</div> Good idea, did not knew that grepping through that file can be that tricky. <br /> Inspired by your post I made a new alias for our AIX Systems. <div>&nbsp;</div> alias hists="strings -n 1 ~/.sh_history | tail -n 500 | grep -v ^hists | grep -i $1" <div>&nbsp;</div> it searches the last 500 .sh_history entries on the given argument. Well ksh is not the most comfortable shell but we can help ourself ... ;) <div>&nbsp;</div> Cheers Sebastian

4 AntonioVasconcelos comentou às Link permanente

You only get the non-printable chars if you have "EXTENDED_HISTORY=ON" on your /etc/environment in order to record execution time besides the command. <div>&nbsp;</div> The correct method of consulting the history file is with the 'fc' command (do a man fc). <br /> Some or maybe all AIX'es come with an alias "history=fc -l" but if you want a more useful printout use "fc -tr 0" (all the history with execution time (if available), reversed) or "fc -t" for only the last 16 commands (not reversed).

5 brian_s comentou às Link permanente

Antonio - I believe the unprintable characters are there irregardless of extended history setting. I am aware of the history/fc commands, however this posting is geared for searching through history files of other user accounts. For example, if you are trying to find out who/what caused an issue on a server, you could search for all history files on the server using find, and then use this "strings" method to grep for suspect commands to narrow down what happened.