Главная страница Статьи / Unix Unix to DOS конвертирование символов переноса строки

Рекомендую - скидка 25%

Баннер

Поиск по сайту

Добавить в закладки!

odnaknopka.ru/kolyan.cz

Unix to DOS конвертирование символов переноса строки PDF Печать E-mail
Статьи - Unix

# tr


You may use tr to remove all carriage returns and Ctrl-z (^Z) characters from a DOS file by entering

  tr -d '\15\32' < dosfile.txt > unixfile.txt

tr cannot be used to convert a document from Unix format to DOS.

# awk


To use awk to convert a DOS file to Unix, at the Unix prompt, enter

  awk '{ sub("\r$", ""); print }' dosfile.txt > unixfile.txt

To convert a Unix file to DOS using awk, at the command line, enter

  awk 'sub("$", "\r")' unixfile.txt > dosfile.txt

On some systems, the version of awk may be old and not include the function sub. If so, try the same command, but with gawk or nawk replacing awk.

# perl


To convert a DOS text file to a Unix text file using Perl, at the Unix shell prompt, enter:

  perl -p -e 's/\r$//' < dosfile.txt > unixfile.txt

To convert from a Unix text file to a DOS text file with Perl, at the Unix shell prompt, enter:

  perl -p -e 's/$/\r/' < unixfile.txt > dosfile.txt

Please note that you must use single quotation marks in either command line. This prevents your shell from trying to evaluate anything inside.

 perl -p -i -e 's/$/\r/ filename

Результат сохраняет в тот же самый файл

 
Документация @ Ihtiandr.Info