komplizierter sed befehl

flappinski

flappinski

Foren As
hallo,
ich dachte, ich koennte schon so einiges, aber hier ist mal ein problem, das ich nicht loesen kann:
ob ihr das mit awk, sed oder perl loest, ist mir egal.
waere sehr dankbar ueber hilfe:

so sieht die datei aus:


Code:
   The anterior border of the parietal cortex
    is the:
    A. parieto-occipital sulcus
    B. the parieto-frontal sulcus
    C. the central sulcus
    D. the lateral fissure
    E. none of the above

    C. the central sulcus

    Which of the following mark the border
    between the pons and midbrain on the
    dorsal surface of the brainstem?
    A. pontomedullary junction
    B. exit of the oculomotor nerve
    C. exit of the trochlear nerve
    D. superior colliculus caudal edge

    C. exit of the trochlear nerve

    The rostral end of the corpus callosum is
    called the:
    A. Genu
    B. Splenium
    C. Body
    D. Anterior Horn

    A. Genu


jetzt soll sich folgendes tun:
1) die zeile vor jeder neuen Frage soll ein bestimmtes zeichen bekommen (meinetwegen "+")
2) die zeile vor jeder neuen Antwort ein anderes (bsp. ",")

also so sollte das ergebnis dann aussehen:

Code:
 +
The anterior border of the parietal cortex
    is the:
    A. parieto-occipital sulcus
    B. the parieto-frontal sulcus
    C. the central sulcus
    D. the lateral fissure
    E. none of the above
,
    C. the central sulcus
+
    Which of the following mark the border
    between the pons and midbrain on the
    dorsal surface of the brainstem?
    A. pontomedullary junction
    B. exit of the oculomotor nerve
    C. exit of the trochlear nerve
    D. superior colliculus caudal edge
,
    C. exit of the trochlear nerve
+
    The rostral end of the corpus callosum is
    called the:
    A. Genu
    B. Splenium
    C. Body
    D. Anterior Horn
,
    A. Genu

geht das?
vielen dank im vorraus schon mal,
Stephan
 
Klar geht das

musst dir eigentlich schauen ob du ne leere Zeile hast, wenn ja gibst du plus aus merkst dir das und gibst als nächstes komma aus

mfg
HeadCrash

Code:
awk ' BEGIN { towrite="+" }
{
        if ( $0 == "" )
        {
                print(towrite)
                if ( towrite == "+" ) towrite=","
                else towrite="+"
        }
        else
        {
                print($0)
        }
}' quelldatei

Musst nur aufpassen das die Eingabedatei wirklich mit ner Leerzeile anfängt und aufhört
 
Zuletzt bearbeitet:

Ähnliche Themen

Zugriff Ubuntu 16.04. auf Freigabe 18.04. LTS nicht möglich

Samba 4 Gast Zugang unter Ubuntu funktioniert nicht

dovecot und postfix Konfiguration Problem

Windows clients können nicht mehr auf lange laufendes System zugreifen

NagiosGrapher 1.7.1 funktioniert nicht

Zurück
Oben