Hinweis, wenn Sie Multi-Byte-Dateien sind konvertieren Sie nehmen müssen besondere Vorsicht, und sollte wahrscheinlich versuchen, die korrekten iconv oder recode von codierenden Spezifikationen zu verwenden.
Wenn es sich um eine einfache ASCII-Datei handelt, funktionieren beide der folgenden Methoden.
Das Programm flip
, in Debian das Paket wird auch flip
genannt, kann mit Zeilenenden umgehen. Aus dem Handbuch:
When asked to convert a file to the same format that it already
has, flip causes no change to the file. Thus to convert all
files to **IX format you can type
flip -u *
and all files will end up right, regardless of whether they were
in MS-DOS or in **IX format to begin with. This also works in the
opposite direction.
Oder könnten Sie GNU Recode:
< /etc/passwd recode ..pc | tee a b > /dev/null
file a b
Ausgang:
a: ASCII text, with CRLF line terminators
b: ASCII text, with CRLF line terminators
Konvertieren in die Unix-Zeilenenden:
recode pc.. a b
file a b
Ausgang:
a: ASCII text
b: ASCII text
Recode abkürzt dos Zeilenende als pc
, so die Logik mit pc..
wird: vom PC-Format auf den Standard konvertieren, die latin1 ist mit Unix-Zeilenenden.
grep -URl^M. | xargs fromdos? – Dalinaum
Das Ubuntu-Paket zur Installation heißt "Tofrodos". – Apalala
Auf tcsh, und wahrscheinlich auch auf csh, können Sie den gleichen Effekt mit 'grep -URl" \ r "erhalten. | xargs fromdos'. – bdesham