[comp.unix.questions] converting PC text files to UNIX WordPerfect

campbell@Thalatta.COM (Bill Campbell) (05/26/90)

In article <21463@boulder.Colorado.EDU> baileyc@tramp.Colorado.EDU (BAILEY CHRISTOPHER R) writes:
>Help, I need to transfer some text/ASCII files generated by a program on
>an IBM AT to our UNIX system, and then edit the files from the UNIX system
>with Word Perfect 4.2 for UNIX.  Everything was fine until we started 
>[deleted]
>So, I need to know what to do in Word Perfect, or I need a wild card expander
>for DOS and UNIX (I process about 40 files each time we do this, so I cna't
>sit there and type DOS2UNIX dosfile > unixfile, etc.
>Thanks!
>.
The only difference I have ever seen between text files on dos
and unix is the the dos files lines all end in \r\n (carriage
return, line feed) and unix files don't have the carriage return.

A very simple program to do this would be: (written as I reply)

:
# remove carriage returns from dos files creating unix equivalents
# USAGE dostounix dosfile unixfile
# (dosfile and unixfile may be empty in which case this is a simple filter

sed 's/^M$//' $1 > $2

exit $?
#end of program

The ^M is an actual carriage return (CTRL-M) since not all
versions of sed will recognize the \r sequence.  To enter this
with the vi editor press <CTRL-V><CTRL-M>, the CTRL-V tells vi to
take the next character literally.
-- 
....microsoft--\                    Bill Campbell; Celestial Software
...uw-entropy----!thebes!camco!bill 6641 East Mercer Way
....fluke------/                    Mercer Island, Wa 98040
....hplsla----/                     (206) 232-4164

venkat@matrix.UUCP (D Venkatrangan) (05/29/90)

In article <21463@boulder.Colorado.EDU> baileyc@tramp.Colorado.EDU (BAILEY CHRISTOPHER R) writes:
>So, I need to know what to do in Word Perfect, or I need a wild card expander
>for DOS and UNIX (I process about 40 files each time we do this, so I cna't
>sit there and type DOS2UNIX dosfile > unixfile, etc.

In DOS, use the following:

for %f in (*.*) do dos2unix dos\%f unix\%f

If you want it in a batch file, use %%f for %f.

In UNIX (csh), use the following:

foreach i (*.*)
unix2dos unix/$i dos/$i
end

Inside vi, use the following key mappings (place these in .vi_init).

map #7 :%s/\([^^V^V^M]\)$/\1\^V^V^V^M/^M:%s/^$/\^V^V^V^M/^M
map #6 :%s/^V^V^M$//^M

The first one will convert a UNIX file into DOS file within vi.
The second one will convert DOS to UNIX. All except the first '^' in #7
(after [) is due to control-key combination.

---------------------------------------------------------------------------
D. Venkatrangan
Matrix Computer Systems, Inc.           7 1/2 Harris Rd, Nashua, NH 03062
suneast!venkat   uunet!matrix!venkat    (603) 888-7790
---------------------------------------------------------------------------