How to convert CarriageReturns in a text file to Unix style ?

W

Wolfgang Hercker

I am editing a perl script under WinXP/Win2000 with an edtior like NotePad or similar.

I intend to let this Perl script run later under Linux/Solaris/Unix.

Hence I have to convert the Win-Carriage Returns to
Unix compatible line feeds (before uploading it through ftp).

How do I do this conversion ? Is there a tool or command which help me to achieve this ?

Wolfgang
 
T

Todd H.

I am editing a perl script under WinXP/Win2000 with an edtior like NotePad or similar.

I intend to let this Perl script run later under Linux/Solaris/Unix.

Hence I have to convert the Win-Carriage Returns to
Unix compatible line feeds (before uploading it through ftp).

How do I do this conversion ? Is there a tool or command which help
me to achieve this ?

dos2unix and unix2dos are teh command line utilities you seek. I
have them installed as part of cygwin (cygwin.com) but i'm not sure
offhand which exact package of cygwin they're in.




$ dos2unix -?
dos2unix version 0.1.3
converts the line endings of text files from
DOS style (0x0d 0x0a) to UNIX style (0x0a)

Usage: dos2unix [OPTION...] [input file list...]

Main options (not all may apply)
-A, --auto Output format will be the opposite of the
autodetected source
format
-D, --u2d Output will be in DOS format
--unix2dos Output will be in DOS format
-U, --d2u Output will be in UNIX format
--dos2unix Output will be in UNIX format
--force Ignore binary file detection
--safe Do not modify binary files

Help options
-?, --help Show this help message
--usage Display brief usage message
--version Display version information
--license Display licensing information

Other arguments
[input file list...] for each file listed, convert in place.
If none specified, then use stdin/stdout



$ unix2dos -?
unix2dos version 0.1.3
converts the line endings of text files from
UNIX style (0x0a) to DOS style (0x0d 0x0a)

Usage: unix2dos [OPTION...] [input file list...]

Main options (not all may apply)
-A, --auto Output format will be the opposite of the
autodetected source
format
-D, --u2d Output will be in DOS format
--unix2dos Output will be in DOS format
-U, --d2u Output will be in UNIX format
--dos2unix Output will be in UNIX format
--force Ignore binary file detection
--safe Do not modify binary files

Help options
-?, --help Show this help message
--usage Display brief usage message
--version Display version information
--license Display licensing information

Other arguments
[input file list...] for each file listed, convert in place.
If none specified, then use stdin/stdout
 
Y

Yves Leclerc

[email protected] (Wolfgang Hercker) said:
I am editing a perl script under WinXP/Win2000 with an edtior like NotePad or similar.

I intend to let this Perl script run later under Linux/Solaris/Unix.

Hence I have to convert the Win-Carriage Returns to
Unix compatible line feeds (before uploading it through ftp).

How do I do this conversion ? Is there a tool or command which help
me to achieve this ?

dos2unix and unix2dos are teh command line utilities you seek. I
have them installed as part of cygwin (cygwin.com) but i'm not sure
offhand which exact package of cygwin they're in.




$ dos2unix -?
dos2unix version 0.1.3
converts the line endings of text files from
DOS style (0x0d 0x0a) to UNIX style (0x0a)

Usage: dos2unix [OPTION...] [input file list...]

Main options (not all may apply)
-A, --auto Output format will be the opposite of the
autodetected source
format
-D, --u2d Output will be in DOS format
--unix2dos Output will be in DOS format
-U, --d2u Output will be in UNIX format
--dos2unix Output will be in UNIX format
--force Ignore binary file detection
--safe Do not modify binary files

Help options
-?, --help Show this help message
--usage Display brief usage message
--version Display version information
--license Display licensing information

Other arguments
[input file list...] for each file listed, convert in place.
If none specified, then use stdin/stdout



$ unix2dos -?
unix2dos version 0.1.3
converts the line endings of text files from
UNIX style (0x0a) to DOS style (0x0d 0x0a)

Usage: unix2dos [OPTION...] [input file list...]

Main options (not all may apply)
-A, --auto Output format will be the opposite of the
autodetected source
format
-D, --u2d Output will be in DOS format
--unix2dos Output will be in DOS format
-U, --d2u Output will be in UNIX format
--dos2unix Output will be in UNIX format
--force Ignore binary file detection
--safe Do not modify binary files

Help options
-?, --help Show this help message
--usage Display brief usage message
--version Display version information
--license Display licensing information

Other arguments
[input file list...] for each file listed, convert in place.
If none specified, then use stdin/stdout

If you transfer the TEXT files with the FTP option of ASCII transfer (ascii ),
the the conversion is "supposed" to be done for you automatically.
 
H

Helge Haensel

Am 23.08.2006, 21:42 Uhr, schrieb Yves Leclerc

<... snipped>


Hi, the freeware editor pspad from www.pspad.com has such a switch
in the Format-menue. Highly recommended.
Helge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top