Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNIX to DOS conversion

Status
Not open for further replies.

pjb

Programmer
May 1, 2001
148
US
I am copying a file from UNIX to an NT server where I have too put the end-of line characters on each record. To do this, I can run the file thru this awk, and it works fine:

awk '{FS="$"; print $1 "^M"}' unixfile > dosfile

Now, to go a step further, is there an easy way to tell if the unix file already has the ^M's, so I won't double them up?
 
Something like this ?
awk '!/\r$/{printf "%s\r\n",$0;next}{print}' unixfile > dosfile
You may also have already an unix2dos command.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks,

Exactly what I was looking for. Yes, I do have a unix2dos command on the box, but if you run a file thru that already has ^M's, it will add another - not good. Your code however will not add another - GOOD!
 
Yes, and I would like to use ftp, but our security people here frown on it. Since we don't have connect direct installed, they like this method the best.
 
Do your security people know about sftp and ssh?
They might like it ...
 
I think I would need something like PUTTY on the NT box to run ssh.
 
Yes;
but I wanted to point you to sftp. It uses the same features for security as ssh, and for the user it works like ftp.
 
Don't have sftp on the NT either, and they won't put in on.
 
On linux, there is a program 'recode' - I don't know whether it tests for the file being already converted:

Code:
decode iso8859-1:cp1252 unixfile > dosfile
when I remember correctly.
It allows conversion between multiple formats.

Another one is frotodos, alias todos, alias unix2dos, fromdos, dos2unix. Don't know about whether it is available for your plattfrom, and recognizes already converted files.

seeking a job as java-programmer in Berlin:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top