The UNIX and Linux Forums  
Ciao e benvenuto da parte degli Stati Uniti al UNIX e Linux Forum! Grazie per la visita ed unirsi alla nostra Comunità Globale.

Go Back   UNIX e Linux Forum > Inizio Forum > Shell scripting e di programmazione
.
google unix.com



Shell scripting e di programmazione Pubblica domande su KSH, CSH, SH, Bash, Perl, PHP, sed, awk e da altri script di shell e linguaggi di scripting shell qui.

Più di UNIX e Linux Forum Argomenti potreste trovare utili
Filo Thread Starter Forum Risposte Ultimo Post
Convertire Epoch Time to Standard & Data e ora Vice Versa DrivesMeCrazy Shell scripting e di programmazione 5 02-07-2009 01:40 AM
Per convertire più file in un formato leggibile in formato ascii gaur.deepti UNIX for Dummies Domande & Risposte 5 03-25-2008 03:03 PM
MMGGAA convertire il formato della data di ccyyddd formato? Bhups Shell scripting e di programmazione 2 09-27-2006 11:30 PM
come convertire il tempo di epoca readible formato? cin2000 Shell scripting e di programmazione 11 12-19-2005 07:14 PM
formato data / ora di presentazione apalex Shell scripting e di programmazione 6 04-19-2002 01:34 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Cerca in questo Thread Rate Thread Modalità di visualizzazione
  #1 (permalink)  
Old 11-18-2008
rk4k rk4k is offline
Utente Registrato
  
 

Iscriviti Data: novembre 2008
Ubicazione: / planet-earth/indonesia/jakarta /
Interventi: 11
Talking Convertire Epoch formato orario a tempo normale data nello stesso formato di file

Ho un file chiamato "sospetto", con serie di linee come queste:

Codice:
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''}
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '87.204.76.129', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 15485, 'time': 1226506312L, 'serverhostname': ''}
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '118.125.238.96', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 23786, 'time': 1226506312L, 'serverhostname': ''}
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '90.4.40.186', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 27542, 'time': 1226506312L, 'serverhostname': ''}
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '84.90.16.109', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 64115, 'time': 1226506312L, 'serverhostname': ''}
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '78.106.166.60', 'client_port': 45309, 'client': '10.64.68.143', 'server_port': 57587, 'time': 1226506312L, 'serverhostname': ''}
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '218.161.75.90', 'client_port': 45309, 'client': '10.64.68.143', 'server_port': 14323, 'time': 1226506312L, 'serverhostname': ''}
{'protocol': 6, 'service': 'BitTorrent encrypted transfer', 'server': '208.53.147.63', 'client_port': 3647, 'client': '10.64.68.68', 'server_port': 31866, 'time': 1226534386L, 'serverhostname': ''}
{'protocol': 6, 'service': 'BitTorrent transfer', 'server': '87.120.14.250', 'client_port': 41607, 'client': '10.64.68.78', 'server_port': 22566, 'time': 1226534379L, 'serverhostname': ''}
{'protocol': 6, 'service': 'HTTP', 'server': '72.14.221.190', 'client_port': 51980, 'client': '10.64.68.68', 'server_port': 80, 'time': 1226880065L, 'serverhostname': ''}
{'protocol': 6, 'service': 'Undetermined', 'server': '92.97.199.57', 'client_port': 55456, 'client': '10.64.68.68', 'server_port': 25252, 'time': 1226880097L, 'serverhostname': ''}
{'protocol': 6, 'service': 'HTTP', 'server': '74.125.19.118', 'client_port': 54043, 'client': '10.64.68.68', 'server_port': 80, 'time': 1226880099L, 'serverhostname': ''}
Voglio convertire il campo che contiene 1226506312L normale formato della data. Ho trovato lo script per la conversione con la data di comando con:

Codice:
date -d '1970-01-01 '$1' seconds'
Vorrei convertire i file in modo che avrà un aspetto simile:

Codice:
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '84.90.16.109', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 64115, 'time': Wed Nov 12 16:11:52, 'serverhostname': ''}
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '78.106.166.60', 'client_port': 45309, 'client': '10.64.68.143', 'server_port': 57587, 'time': Wed Nov 12 16:11:52, 'serverhostname': ''}
{'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '218.161.75.90', 'client_port': 45309, 'client': '10.64.68.143', 'server_port': 14323, 'time': Wed Nov 12 16:11:52, 'serverhostname': ''}
{'protocol': 6, 'service': 'BitTorrent encrypted transfer', 'server': '208.53.147.63', 'client_port': 3647, 'client': '10.64.68.68', 'server_port': 31866, 'time': Wed Nov 12 23:59:46 WIT 2008, 'serverhostname': ''}
{'protocol': 6, 'service': 'BitTorrent transfer', 'server': '87.120.14.250', 'client_port': 41607, 'client': '10.64.68.78', 'server_port': 22566, 'time': Wed Nov 12 23:59:46 WIT 2008, 'serverhostname': ''}
{'protocol': 6, 'service': 'HTTP', 'server': '72.14.221.190', 'client_port': 51980, 'client': '10.64.68.68', 'server_port': 80, 'time': Wed Nov 12 23:59:46 WIT 2008, 'serverhostname': ''}
{'protocol': 6, 'service': 'Undetermined', 'server': '92.97.199.57', 'client_port': 55456, 'client': '10.64.68.68', 'server_port': 25252, 'time': Wed Nov 12 23:59:46 WIT 2008, 'serverhostname': ''}
{'protocol': 6, 'service': 'HTTP', 'server': '74.125.19.118', 'client_port': 54043, 'client': '10.64.68.68', 'server_port': 80, 'time': Wed Nov 12 23:59:46 WIT 2008, 'serverhostname': ''}
Conosco un po 'di awk, e può convertire con:

Codice:
awk '{ print $7 }' FS="," suspected | awk '{ print $2 }' | cut -f1 -d"L" | while read line ; do sh datepoch $line ; done
ma lo script appena convertire e la data di uscita campo.

Come convertire e anche sostituire il formato della data per lo stesso file?

Grazie per qualsiasi aiuto.

Saluti
 

Segnalibri

Tag
awk, sed, sostituto

Thread Tools Cerca in questo Thread
Cerca in questo Thread:

Ricerca Avanzata
Modalità di visualizzazione Vota questo thread
Vota questo thread:

Distacco regolamento
Tu non può post nuovo thread
Tu non può inviare una risposta
Tu non può postare allegati
Tu non può modificare i tuoi post

BB codice è Su
Smilies sono Su
[IMG] codice Su
Codice HTML è Chiuso
Trackbacks sono Su
Pingbacks sono Su
Refbacks sono Su




Tutti gli orari sono GMT -4. La data di oggi è 01:16 PM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Traduzioni Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
UNIX e Linux Forum Content Copyright © 1993-2009. Tutti i diritti Reserved.Ad di gestione da RedTyger

Contenuti pertinenti URL da vBSEO 3.2.0