Unix to Windows CRLF

Hi ya,

I FTP a file from a Unix box to a Windows FTP Sever in binary mode.  The line feed character from Unix does not get converted to CRLF in Windows since I am in binary mode.  Is there a way in Unix to change the LF  to Windows compatable CRLF? I would prefer to use a built in Unix command instead of a third party utility.  

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vi filename
:set list show

replace all $ with ^M


thing that should work
jmnasonAuthor Commented:
Thanks Satalink, but I want some command that I can automate my process. I create a XML file in Unix, encrypt it and send the file to the windows FTP server and this is automated.
There are several tools to accomplish that, the most common (and likely to be installed) are

unix2dos <filename>


recode lat1..ibmpc <filename>
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

BTW, the 1st one usually is implemented as a 'shell alias' like

   alias unix2dos='recode lat1..ibmpc'
   alias dos2unix='recode ibmpc..lat1'
Just to mention them, sed oneliners found on http://sed.sourceforge.net/sed1line.txt

 # IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format
 sed "s/$/`echo -e \\\r`/"            # command line under ksh
 sed 's/$'"/`echo \\\r`/"             # command line under bash
 sed "s/$/`echo \\\r`/"               # command line under zsh
 sed 's/$/\r/'                        # gsed 3.02.80

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Is your file will be bad if ftp in ascii mode?
'cause you did not tell us your UNIX flaviour, and unfortunately each has its own program/script/alias/whatever to do it, I'd sugest a general perl solution:
perl -pe 'BEGIN{ $/="\012"; $\="\015\012"} chomp' unixfile >dosfile
Why not just FTP the file in ASCII mode?  Much simpler.
>>Why not just FTP the file in ASCII mode?

Because the files will still get displayed incorrectly in Windows applications...
>>Why not just FTP the file in ASCII mode?

'cause you never know how  "ASCII"-mode is defined in your ftp client *and* ftpd-server, be prepared for surprises ...

Agree with your comments about ftp client/server, *but* if you have a known environment, you know what client/server you operate and will know whether ASCII transfers work as they should.
agreed, but if you know all this, then there's no need for this question :-))
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.