Pagina 1 di 1

Informazioni file bash history(Risolto)

Inviato: domenica 9 gennaio 2011, 17:41
da francok
Non ricordo come ho fatto,ma avevo fatto in modo di avere delle informazioni sui comandi che davo da terminale,che si memorizzavano nel file bash history,dovevano essere data e ora se non ricordo male,ma ottengo solo questo:
uname -a
#1292420013      
#1292600256
free
#1292608478

Come faccio a levarli?

Re: Informazioni file bash history

Inviato: domenica 9 gennaio 2011, 19:43
da Elrond
francok ha scritto: Non ricordo come ho fatto,ma avevo fatto in modo di avere delle informazioni sui comandi che davo da terminale,che si memorizzavano nel file bash history,dovevano essere data e ora se non ricordo male,ma ottengo solo questo:
uname -a
#1292420013
xeyes
#1292600256
free
#1292608478

Come faccio a levarli?
È possibile che nel tuo file ~/.bashrc abbia aggiunto qualcosa riguardo la variabile HISTTIMEFORMAT? Apri il file con un editor di testo e se trovi una linea riguardo questa variabile cancellala. Se non sta in quel file potrebbe stare in qualche altro file nascosto della home. Senza perdere tempo puoi cercare così:

Codice: Seleziona tutto

grep  HISTTIMEFORMAT ~/*
Funzionerà se hai fatto effettivamente questa modifica, in caso contrario...  :-\

Re: Informazioni file bash history

Inviato: domenica 9 gennaio 2011, 20:01
da francok
Ho provato il comando ma nulla da fare
grazie

Re: Informazioni file bash history

Inviato: lunedì 10 gennaio 2011, 0:07
da Elrond
francok ha scritto: Ho provato il comando ma nulla da fare
grazie
Cioè hai aperto il file ~/.bashrc e non hai trovato nessuna dichiarazione della variabile HISTTIMEFORMAT? Per il comando ho sbagliato io, usa questo:

Codice: Seleziona tutto

grep HISTTIMEFORMAT ~/.*

Re: Informazioni file bash history

Inviato: lunedì 10 gennaio 2011, 0:37
da francok
Se ho aperto il file giusto ho trovato questo:  (non copio tutto)

Codice: Seleziona tutto

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
fi
export HISTTIMEFORMAT="%d/%m/%y %T "
Invece il comando restituisce
/home/franco/.bash_history:grep HISTTIMEFORMAT ~/.*
/home/franco/.bashrc:export HISTTIMEFORMAT="%d/%m/%y %T "

Ho fatto caso che il comando che hai messo tu,non lascia numeri in bash history come tutti gli altri comandi

Re: Informazioni file bash history

Inviato: lunedì 10 gennaio 2011, 1:05
da Elrond
Cancella la riga

Codice: Seleziona tutto

export HISTTIMEFORMAT="%d/%m/%y %T "
dal file ~/.bashrc e hai risolto. Sembra che la variabile HISTTIMEFORMAT non venga interpretata correttamente dalla bash, qualunque sia il suo valore la data viene mostrata come Unix time (il fatto che nel file di history compare

Codice: Seleziona tutto

#1292420013
xeyes
#1292600256
free
e non

Codice: Seleziona tutto

1292420013 xeyes
1292600256 free
è spiegato nel manuale di bash:
man bash-builtins ha scritto:              If the HISTTIMEFORMAT variable is set, the time stamp information associated with  each  history  entry  is
              written  to  the  history  file, marked with the history comment character.  When the history file is read,
              lines beginning with the history comment character followed immediately by a digit are interpreted as time‐
              stamps  for  the  previous history line.

Re: Informazioni file bash history

Inviato: lunedì 10 gennaio 2011, 1:23
da francok
Fatto tutto a posto
grazie mille  (good)

Re: Informazioni file bash history(Risolto)

Inviato: lunedì 10 gennaio 2011, 21:43
da Elrond
Mi piacerebbe capire se il problema della mancata interpretazione della variabile si ha solo in Ubuntu o anche in altre distro  ::)