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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print to a windows file

Status
Not open for further replies.

desanti

Programmer
Jul 9, 2004
51
0
0
US
Hi: i sometimes print to a file on my desktop(windows).the problem is that the file prints with LF(hex 0a) linux style.windows uses a hex(0d 0a--crlf).when printing to a file how can i get the file to print windows style without using a program;if that is possible?P.S. i have a program that will sustitute CRLF for LF but it does'nt always work.
think printing a year using CAL.thank you.
 
Doesn't have linux unix2dos ?
Anyway, as you posted in the awk forum:
awk '{printf "%s\r\n",$0}' /path/to/linuxfile > /path/to/windowsfile

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Set the output record separator,e.g..
[tt]
BEGIN { ORS = sprintf("\015\012") }
[/tt]
Or maybe just...
[tt]
BEGIN { ORS = "\r\n" }
[/tt]
 
PHV the solution you described does put the file in the format BUT not 100%.if you CAL --y to file and then use
your solution you will see what i mean.the cal --y to the screen is fine.also,i investigated the unix2dos and by using the description provided:
cat file | sed "s/$/^M/" | sed "$ s/$/^Z/" > file.new does
not seem to work 100%.thank you.
 
Sorry, I don't play linux, so I don't see what you mean with cal --y
 
PHV:cal --y is a program/function to print the current year in a calendar format.i believe about 30 years ago that existed in unix.i could be wrong.thanx
 
I know the cal utility but can't figure out the --y option.
 
PHV; as i understand it the utility with the --y prints out the calander for the year otherwise it prints the current
month.
 
I did execute the following command and still don't see the problem:
cal 2005 | awk '{printf "%s\r\n",$0}' >winfile.txt

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top