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
fusione di due file vakharia Mahesh Shell scripting e di programmazione 7 09-15-2008 12:32 PM
La fusione di array jakSun8 Shell scripting e di programmazione 4 07-01-2008 11:13 PM
Unire due file venommaker UNIX for Dummies Domande & Risposte 4 01-10-2008 08:15 AM
Fondere info Manan Shell scripting e di programmazione 3 05-20-2006 07:51 AM
Fondere Aiuto kumarc Shell scripting e di programmazione 3 05-04-2006 02:24 PM

Closed Thread
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 01-05-2009
ssachins ssachins is offline
Utente Registrato
  
 

Iscriviti Data: gennaio 2009
Interventi: 29
Fusione delle righe

Ciao ragazzi,

Auguriamo tutti un Felice Anno Nuovo!.

Grazie in anticipo.

Voglio leggere un file e unire le righe che hanno un '\ n' in esso.
Il file potrebbe essere> 50.000 byte. Lo script dovrebbe unire tutte le righe fino alla riga successiva inizia con la parola 'Tipo |'.
ex.
Tipo | Ticket | TradeID | 42224A | SystemID | DDDD61266 | SourceSystem | RMS | Version | 5 | LatestVersionYN | Y | Counterpa rty | OB | DBLegalEntity | Londra | Note | cal eventi aggiunto | venditore | DHX | LastUpdated | dic 2008 18:31 : 40 | Azione | Exp | DealCaptureSystem | Vendite | CustomerSourceSystem | RMS | Servizio Clienti | AUGS | ActionEffectiveDa te | DEC 2008 00:00:00 | BookingLocation | Londra | EnteredBy | GONU | MarkupAmt | 100 | MarkupCcy | KEX | PremiumCurrency | EUR | Premi umAmount | 000 | PremiumDate | dic 2008 | PremiumHasPaidYN | N | BookingDetails | 9000/mihl
Cliente vende KEZUSD
rif st 1,3724
Leveraged Sele è ST
52 Sele, a partire


Tipo | FxDiscreteDNT | TradeID | SSA32553H | SystemID | GGT04481 | SourceSystem | RMS | SourceSystemBook | OT | Prenotare | OT | BookBranchParent | Vai | Version | 8 | LatestVersionYN | Y | Controparte | DOB | Stato | KnockedOut | IsLiveYN | N | DBLega lEntity | Londra | LastUpdated | GEN 2009 00:26:35 | Azione | KnockedOut | CounterpartySourcesystem | RMS | TradeDate | lug 2006 | ProductID | KKI99106 | StructureID | DDS32553 | DealCaptureSystem | RMS | CustomerSourceSystem | RMS | Servizio Clienti | APS | PricingSite | Opzioni | UnderCurrency1 | JPY | AccCurrency1 | US | UpBarrier1 | 1,5 | LowBarrier1 | 1 | UnderCurrenc y2 | JPY | AccCurrency2 | CH | UpBarrier2 | 1,64 | LowBarrier2 | 1,49 | UnderCurrency3 | EUR | AccCurrency3 | JPY | UpBarrie r3 | 175 | LowBarrier3 | 105 | LastFixed

Il outout dovrebbe essere
La registrazione che dovrebbe essere al di sotto di una sola riga.

Tipo | Ticket | TradeID | 42224A | SystemID | DDDD61266 | SourceSystem | RMS | Version | 5 | LatestVersionYN | Y | Counterpa rty | OB | DBLegalEntity | Londra | Note | cal eventi aggiunto | venditore | DHX | LastUpdated | dic 2008 18:31 : 40 | Azione | Exp | DealCaptureSystem | Vendite | CustomerSourceSystem | RMS | Servizio Clienti | AUGS | ActionEffectiveDa te | DEC 2008 00:00:00 | BookingLocation | Londra | EnteredBy | GONU | MarkupAmt | 100 | MarkupCcy | KEX | PremiumCurrency | EUR | Premi umAmount | 000 | PremiumDate | dic 2008 | PremiumHasPaidYN | N | BookingDetails | 9000/mihl Cliente vende KEZUSD ° rif 1,3724 Leveraged Sele si trova a 52 ST Sele, a partire

Tipo | FxDiscreteDNT | TradeID | SSA32553H | SystemID | GGT04481 | SourceSystem | RMS | Version | 8 | LatestVersionYN | Y | Controparte | DOB | DBLegalEntity | Londra | LastUpdated | GEN 2009 00:26:35 | Azione | KnockedOut | DealCaptureSystem | RMS | CustomerSourceSystem | RMS | Servizio Clienti | APS | PricingSite | O ption | UnderCurrency1 | JPY | AccCurrency1 | US | UnderCurrency3 | EUR | AccCurrency3 | JPY | UpBarrier3 | 175 | LowBarri er3 | 105 | LastFixed

Ho provato a utilizzare lo script qui di seguito menzionati, ma non può gestire AWK> 20.000 byte. Inoltre, utilizzando come stringa 'LINE_BREAK' per identificare le righe si è fusa.

FileName \u003d LINE_TEST.TXT
Nomefile1 \u003d O_LINE_TEST.TXT
File_output \u003d OUTPUT_WITHOUT_LINE_BREAK.tmp
if [[-e $ filename]], quindi
sed "s /% / percentuale / g" $ filename> $ nomefile1
# # Per rimuovere '%', come 'awk' non può gestire la cosa.

/ usr/xpg4/bin/awk 'NR \u003d\u003d 1 (printf $ 0;) accanto
! / ^ TradeType / (printf "LINE_BREAK" $ 0;) accanto
(printf "\ n" $ 0)
END (print "")
'$ Nomefile1> $ file_output
fi
  #2 (permalink)  
Old 01-05-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Iscriviti Data: gennaio 2007
Ubicazione: Варна, България / Milano, Italia
Interventi: 2.859
Prova con nawk:

Codice:
nawk '$1=$1' FS='\n' RS= ORS='\n\n' infile
  #3 (permalink)  
Old 01-05-2009
ssachins ssachins is offline
Utente Registrato
  
 

Iscriviti Data: gennaio 2009
Interventi: 29
La fusione di righe - errore

Io sono sempre al di sotto di cui il messaggio di errore:

13460 Segmentation Fault (coredump). E 'connesse Memoria?

La dimensione del file è il seguente: 95532469 bytes.
  #4 (permalink)  
Old 01-05-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Iscriviti Data: gennaio 2007
Ubicazione: Варна, България / Milano, Italia
Interventi: 2.859
Prova con Perl:

Codice:
perl -00ple'tr.\n. .' infile
  #5 (permalink)  
Old 01-05-2009
ssachins ssachins is offline
Utente Registrato
  
 

Iscriviti Data: gennaio 2009
Interventi: 29
Identificare

Come identfy le linee che sono state fuse durante l'elaborazione del file?
  #6 (permalink)  
Old 01-05-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Iscriviti Data: gennaio 2007
Ubicazione: Варна, България / Milano, Italia
Interventi: 2.859
Citazione:
Originalmente inviato da ssachins View Post
Come identfy le linee che sono state fuse durante l'elaborazione del file?
Basta aggiungere qualche stringa di identificare loro:

Codice:
perl -00ple'tr.\n. . and $_.=" __FIXED__"' infile
  #7 (permalink)  
Old 01-06-2009
frostmourn frostmourn is offline
Utente Registrato
  
 

Iscriviti Data: gennaio 2009
Posti: 8
Codice:
sed '/^Type/{:a;N;/\nType/!{s/\n/ /;ba};s/\n/&&/}'
Closed Thread

Segnalibri

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 è 10:35 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