Wir haben eine Shell-Skript-Datei mit dem Namen LineFeed.sh
, die eine Funktion zum Umwandeln eines Zeilenvorschubs (LF
) in Carriage Return + LineFeed ausführt. Wir wollen das Gleiche mit einer Batch-Datei in Windows machen. Ist es möglich?Batch-Datei + LF in CR + LF konvertieren
Linux-Shell-Datei
E_WRONGARGS=65
cat OutputList|while read -r Line
do
if [ -z "$Line" ]
then
echo "Usage: `basename $0` filename-to-convert"
exit $E_WRONGARGS
fi
NEWFILENAME=$Line.unx
CR='\015' # Carriage return.
# 015 is octal ASCII code for CR.
# Lines in a DOS text file end in CR-LF.
# Lines in a UNIX text file end in LF only.
tr -d $CR < $1 > $NEWFILENAME // here its deleting CR but i need to append LF
# Delete CR's and write to new file.
done
echo "Original DOS text file is \"$1\"."
echo "Converted UNIX text file is \"$NEWFILENAME\"."
exit 0
http://www.google.com/search?q=unix2dos.bat – Heinzi
@Heinzi: http://meta.stackexchange.com/questions/5280/embrace-the-non-googlers – Joey
@Johannes: Eigentlich , mein Kommentar googelte nicht nur die Frage, sondern enthielt eine Antwort. Ja, ich war übermäßig kurz; Die ausführliche Version wäre: "Sie müssen das nicht selbst tun; es gibt ein Skript namens unix2dos, das genau das tut, was Sie wollen, und es gibt Windows-Ports, normalerweise' unix2dos.bat' genannt. Wenn Sie nach diesem Schlüsselwort googlen, Sie werden viele Quellen finden, um es herunterzuladen. " (Trotzdem, ich verstehe Ihren Punkt, danke für den Link.) – Heinzi