Moreutils: aggiungere un timestamp ai comandi in Linux con ts
Moreutils è un insieme di comandi che estendono quelli base che troviamo in Linux.
A dire il vero non tutti sono utili; oggi vediamo uno di quelli che ho usato: ts!
Prima di tutto installiamo il programma:
# aptitude install moreutils
Questo comando ci permette di aggiungere un timestamp all'output di un comando.
Guardiamo questo esempio:
$ ls -l
totale 36
drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Documenti
drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Immagini
drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Modelli
drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Musica
drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Pubblici
drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Scaricati
drwxr-xr-x 3 matte-server matte-server 4096 nov 16 14:59 Scrivania
drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Video
Guardate la differenza se usiamo ts:
$ ls -l | ts
nov 19 15:05:19 totale 36
nov 19 15:05:19 drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Documenti
nov 19 15:05:19 drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Immagini
nov 19 15:05:19 drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Modelli
nov 19 15:05:19 drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Musica
nov 19 15:05:19 drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Pubblici
nov 19 15:05:19 drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Scaricati
nov 19 15:05:19 drwxr-xr-x 3 matte-server matte-server 4096 nov 16 14:59 Scrivania
nov 19 15:05:19 drwxr-xr-x 2 matte-server matte-server 4096 ott 19 20:44 Video
Come vedete è stata aggiunta una colonna con il timestamp.
Questo può essere comodo anche quando mandiamo l'output su file, in modo da ritrovare più facilmente la data di una riga.
Enjoy!
linux moreutils ts timestamp
Commentami!