Coding help with export
Bob Stockler
bob at trebor.iglou.com
Thu Apr 12 11:18:02 PDT 2007
Del wrote (on Thu, Apr 12, 2007 at 01:49:28PM -0500):
| Hi:
|
| I feel dumb asking this, but I have wasted a lot of time already without a solution, so maybe it is not as easy as I thought it should be, either that or my brain is just not with it today (if so, not the first time).
|
| Under SCO Unix, I am using the "export word" command to produce a flat ASCII file. Export word defaults to a record (or line) delimiter of \n (newline). I want to change this to \r\n (carriage return/newline) for compatibility with some windows software that the data is passed to. Well, I have not been able to find any way to do this with "export word" or even with "export ascii" where I thought I could use r=\r\n, but this gives me a syntax error.
|
| I even tried to issue a SED substitution command after generating the output file:
|
| sed s/\n/\r\n/ filename >target filename
| sed s/"\n"/"\r\n"/ filename >target filename
|
| I also tried:
|
| tr "\n" "\r\n" - this changed the \n to \r but not to \r\n.
|
| None of this worked, I really don't know much about sed or tr and regular expressions, but thought this had a shot.
|
| So is there any way to export an ASCII file and generate a record delimiter of carriage return/linefeed? Or convert it after generating it with standard Unix commands?
I've quit using EXPORT in favor of filePro File I/O, but if
you're getting what you want except for the carriage returns,
this little AWK script should edit your file (in place) and
put them in there for you.
#!/bin/ksh
FILE=/path/to/your/file
awk -v FILE="$FILE" '{ line[++n] = $0 "\r" }
END { for (i=1;i<=n;i++) print line[i] > FILE }' $FILE
Bob
--
Bob Stockler +-+ bob at trebor.iglou.com +-+ http://members.iglou.com/trebor
More information about the Filepro-list
mailing list