Newsgroups: comp.sys.apple2 Path: news.weeg.uiowa.edu!news.uiowa.edu!hobbes.physics.uiowa.edu!moe.ksu.ksu.edu!crcnis1.unl.edu!wupost!gumby!destroyer!nntp.cs.ubc.ca!cs.ubc.ca!unixg.ubc.ca!acs.ucalgary.ca!sbdocker From: sbdocker@acs.ucalgary.ca (Sean Brendan Dockery) Subject: Re: How to convert LF's to CR's in UNIX? Message-ID: Date: Sun, 29 Aug 1993 19:16:51 GMT References: Organization: Griffin Software Development Lines: 99 In article kenh@pacifier.rain.com (Ken Hoffmann) writes: | Hello net brethren, I remeber seeing a c-shell script that would | take a UNIX text file and convert it to a Apple readable format, anyone | know where that went? And if someone has it, please mail it to me. There were a few problems that popped up with the previous posting (as I was doing it from memory), but I didn't bother to make any more corrections as people didn't seem to be complaining to me about the scripts not working. I have elected to post it instead of mailing it because the old csh script postings didn't work properly anyway. Anyways, here are the proper working versions (tested and everything). -u2aii converts UNIX LFs to Apple II CRs. -maketext converts files to readable ASCII text -striplf removes LFs from input files in case character streams were truncated to 255 characters by news readers or other utilities. Warning: All of these will destroy binary files. ------------------------------- u2aii ------------------------------- #!/bin/csh -f # u2aii: convert UNIX newlines to Apple II newlines. # find the command name. set cmd=$0:t # if no files are given, then we can't do anything. if ( $#argv == 0 ) then echo "usage: $cmd " exit 1 endif # do the conversion for each file (which is not a directory). foreach file ($*) if ( -f $file ) then (cat $file | tr '\012' '\015') >! /tmp/xxx mv -f /tmp/xxx $file endif end ------------------------------ maketext ------------------------------ #!/bin/csh -f # maketext: strip bit 7 of every byte in input files. # find the command name. set cmd=$0:t # if no files are given, then we can't do anything. if ( $#argv == 0 ) then echo "usage: $cmd " exit 1 endif # do the conversion for each file (which is not a directory). foreach file ($*) if ( -f $file ) then (cat $file | tr '[\201-\377]' '[\001-\177]') >! /tmp/xxx mv -f /tmp/xxx $file endif end ------------------------------ striplf ------------------------------ #!/bin/csh -f # striplf: concatenate lines of text which have been truncated to 255 # characters terminated with LFs. # find the command name. set cmd=$0:t # if no files are given, then we can't do anything. if ( $#argv == 0 ) then echo "usage: $cmd " exit 1 endif # do the conversion for each file (which is not a directory). foreach file ($*) if ( -f $file ) then (cat $file | tr -d '\012') >! /tmp/xxx mv -f /tmp/xxx $file endif end --------------------------------------------------------------------- | Thanks alot, | | Ken Your welcome. I'm just glad somebody is going to use these. -- internet: dockery@griffin.cuc.ab.ca -or- sbdocker@acs.ucalgary.ca -or- dockery@pro-calgary.cts.com pro-line: dockery@pro-calgary Newsgroups: comp.sys.apple2 Path: news.weeg.uiowa.edu!news.uiowa.edu!hobbes.physics.uiowa.edu!moe.ksu.ksu.edu!vixen.cso.uiuc.edu!howland.reston.ans.net!gatech!destroyer!nntp.cs.ubc.ca!cs.ubc.ca!unixg.ubc.ca!acs.ucalgary.ca!sbdocker From: sbdocker@acs.ucalgary.ca (Sean Brendan Dockery) Subject: Re: How to convert LF's to CR's in UNIX? Message-ID: Date: Sun, 29 Aug 1993 19:23:40 GMT References: Organization: Griffin Software Development Lines: 25 Sheesh! Will I ever get those scripts perfected? In the previous posting, change the lines set cmd=$0:t to set cmd=$0 and the lines echo "usage: $cmd " to echo "usage: $cmd:t " This doesn't affect functionality, but it is more asthetically pleasing with the changes in place. -- internet: dockery@griffin.cuc.ab.ca -or- sbdocker@acs.ucalgary.ca -or- dockery@pro-calgary.cts.com pro-line: dockery@pro-calgary