Programma di backup

Grazie Luca. Semplicissimo. un ultima cosa, una volta sapevo come ricercare sempre da console, nello storico appunto di bash_history i comandi che mi serviva riprendere e lo facevo digitando una stringa relativamente semplice da linea di comando. non mi pare che sia con find, ma non so forse mi sbaglio. Se mi dai solo un suggerimento poi ritorno a studiarmelo bene.
Grazie
Giorgio

dovrebbe essere

$ history

ha diverse opzioni che ti lascio studiare

ad esempio con

$ history 10

vedi gli ultimi 10 comandi

con

$ history -c

cancelli tutte le voci e ti garantisco che funziona :wink:

       history [n]
       history -c
       history -d offset
       history -anrw [filename]
       history -p arg [arg ...]
       history -s arg [arg ...]
              With no options, display the command history list with line numbers.  Lines listed with a * have been modified.  An  argu‐
              ment  of  n lists only the last n lines.  If the shell variable HISTTIMEFORMAT is set and not null, it is used as a format
              string for strftime(3) to display the time stamp associated with each displayed history entry.  No  intervening  blank  is
              printed  between  the  formatted  time stamp and the history line.  If filename is supplied, it is used as the name of the
              history file; if not, the value of HISTFILE is used.  Options, if supplied, have the following meanings:
              -c     Clear the history list by deleting all the entries.
              -d offset
                     Delete the history entry at position offset.
              -a     Append the ``new'' history lines (history lines entered since the beginning of the current  bash  session)  to  the
                     history file.
              -n     Read  the  history  lines  not  already  read from the history file into the current history list.  These are lines
                     appended to the history file since the beginning of the current bash session.
              -r     Read the contents of the history file and append them to the current history list.
              -w     Write the current history list to the history file, overwriting the history file's contents.
              -p     Perform history substitution on the following args and display the result on the standard output.  Does  not  store
                     the results in the history list.  Each arg must be quoted to disable normal history expansion.
              -s     Store  the  args in the history list as a single entry.  The last command in the history list is removed before the
                     args are added.

              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 timestamps for the previous history line.  The return
              value  is 0 unless an invalid option is encountered, an error occurs while reading or writing the history file, an invalid
              offset is supplied as an argument to -d, or the history expansion supplied as an argument to -p fails.
2 Likes

Grazie.

Se digiti
$ history
si ha un elenco dei comandi, ognuno preceduto da un numero di riferimento dove 1 è il comando più recente e via via gli altri in ordine di tempo inverso.
Mi sembra di ricordare che ci fosse una sintassi per richiamare il comando esatto di una determinata riga, includendo appunto il numero di riferimento.
:thinking: :question:

PS>
history funziona sia nella console di utente che nella console di root, e ovviamente ti verranno mostrate due diverse serie di comandi.

PS2>
Un’altra cosa che ricordo ma non ricordo :stuck_out_tongue: è che c’era un comando per eliminare le righe uguali.
Cioè per fare un esempio se hai dato urpmi --auto-update una dozzina di volte, ne viene mantenuta solo una riga nello storico invece che 12.

$ !10

esegue il comando della riga 10

1 Like

se le volte sono consecutive dovrebbe già essere così di default

Bravissimo :clap:
Proprio quello :thumbsup:

No, non intendevo consecutive ma proprio tutte le righe uguali nello storico, anche se digitate in momenti diversi con altri comandi nel mezzo :slight_smile:

a volte è comodo usarlo anche digitando parte del comando:

$ !moun

eseguirà l’ultimo mount eseguito

mentre

$ !-2

eseguirà il penultimo comando

1 Like

questa non la sapevo :wink:
http://www.linuxjournal.com/content/using-bash-history-more-efficiently-histcontrol

1 Like

C’è sempre il classico:
There is always the classic:

# rm -rf /

Corre praticamente qualsiasi cosa…
fixes practically anything…

1 Like

:astonished:
Nooooo! :joy:

Grazie Amici. Siete fantastici!!! È proprio il caso di dire che vi prenderò alla lettera!!! Tranne ono!!! :grinning:
Grazie a Tutti. Anche a Ben. !!
Giorgio