Depende del shell (y su configuración) en bash estándar solo el comando se almacena sin la fecha y la hora (marque .bash_history
si hay alguna marca de tiempo allí).
Para que bash almacene la marca de tiempo, debe configurar HISTTIMEFORMAT
antes ejecutando los comandos, p. en .bashrc
o .bash_profile
. Esto hará que bash almacene las marcas de tiempo en .bash_history
(ver las entradas que comienzan con #
).
Con respecto a este enlace, puede hacer que la primera solución proporcionada por krzyk sea permanente ejecutando:
echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
source ~/.bash_profile
Prueba esto:
> HISTTIMEFORMAT="%d/%m/%y %T "
> history
Puedes ajustar el formato a tu gusto, por supuesto.
En caso de que esté usando zsh, puede usar, por ejemplo, el -E
o -i
cambiar:
history -E
Si haces un man zshoptions
o man zshbuiltins
puede encontrar más información sobre estos interruptores, así como otra información relacionada con el historial:
Also when listing,
-d prints timestamps for each event
-f prints full time-date stamps in the US `MM/DD/YY hh:mm' format
-E prints full time-date stamps in the European `dd.mm.yyyy hh:mm' format
-i prints full time-date stamps in ISO8601 `yyyy-mm-dd hh:mm' format
-t fmt prints time and date stamps in the given format; fmt is formatted with the strftime function with the zsh extensions described for the %D{string} prompt format in the section EXPANSION OF PROMPT SEQUENCES in zshmisc(1). The resulting formatted string must be no more than 256 characters or will not be printed
-D prints elapsed times; may be combined with one of the options above