Ich mache ein Tutorial in der Befehlszeile. In einer der Übungen muss ich eine sonnet und echo
in eine neue Datei kopieren. Problem ist, dass die neuen Zeilen nicht in der neuen Datei vorhanden sind, in der Tat, wenn ich die Datei cat
, jeder Vers an den vorherigen angehängt ist.Kopieren, Einfügen und Echo in txt-Datei mit Zeilenumbrüchen
Muss ich am Ende jeder Zeile manuell "\n"
hinzufügen? Ich hoffe, es gibt einen besseren Weg
UPDATE (weil das, was, wenn es 1000 Zeilen sind?): Dies ist, was ich bis jetzt
Erste getan haben kopiere ich das Sonett von here. Dann füge ich es im Terminal diesen Befehl zu schreiben:
~$ echo "FRom faireſt creatures we deſire increaſe, That thereby beauties Roſe might neuer die, But as the riper ſhould by time deceaſe, His tender heire might beare his memory: But thou contracted to thine owne bright eyes, Feed’ſt thy lights flame with ſelfe ſubſtantiall fewell, Making a famine where aboundance lies, Thy ſelfe thy foe,to thy ſweet ſelfe too cruell: Thou that art now the worlds freſh ornament, And only herauld to the gaudy ſpring, Within thine owne bud burieſt thy content, And tender chorle makſt waſt in niggarding: Pitty the world,or elſe this glutton be, To eate the worlds due,by the graue and thee." > sonnet.txt
schließlich prüfe ich den Inhalt:
cat sonnet.txt
aber ich bekomme:
FRom faireſt creatures we deſire increaſe, That thereby beauties Roſe might neuer die, But as the riper ſhould by time deceaſe, His tender heire might beare his memory: But thou contracted to thine owne bright eyes, Feed’ſt thy lights flame with ſelfe ſubſtantiall fewell, Making a famine where aboundance lies, Thy ſelfe thy foe,to thy ſweet ſelfe too cruell: Thou that art now the worlds freſh ornament, And only herauld to the gaudy ſpring, Within thine owne bud burieſt thy content, And tender chorle makſt waſt in niggarding: Pitty the world,or elſe this glutton be, To eate the worlds due,by the graue and thee.
Haben _copy-paste ein Sonnet_ nicht erhalten. Ist _sonnet_ eine Zeichendatei oder etwas anderes? – Mahendra
Welchen Befehl verwenden Sie, um dies zu tun? 'echo [einfügen]> Datei'? Enthält der eingefügte Inhalt Leerzeilen zwischen jedem Vers? –
@Mahendra, Tut mir leid, ich habe vergessen, einen Link – Pigna