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

vi wont open MAC os 9 files - line to long

Status
Not open for further replies.

shodan81

MIS
Jan 12, 2000
1
GB
When opening Apple MAC documents that have been created on OS 9 vi reports that the line is to long. The Mac files have no line feed character and to vi the file appears to be one long line. <br>
I've tried using sed to modify the file and add a line feed but I cannot get the line feed character in. When I used Ctrl v j all I get from unix is a new line, I've tried using a script <br>
#!/bin/sh<br>
<br>
sed 's/ctrl v m/ ctrl v <br>
j /' $1 $2<br>
<br>
where $1 = file $2 =newfile<br>
but it wont work - it might be me of course<br>
<br>
so is there anyway to change ^M to ^M^J in a file - or AITDTWWC<br>
<br>
Thanks in anticipation <br>
Gordon<br>
Sorry shodan81<br>

 
Have you got perl? You migh have without noticing - type perl and press enter.<br>
<br>
if you have...<br>
<br>
Put this in a file ('tryit.pl' for eg) and chmod +x that file<br>
--snip--<br>
#!/local/bin/perl<br>
<br>
while(&lt;&gt;){<br>
&nbsp;&nbsp;&nbsp;&nbsp;s/\m/\n/go;<br>
&nbsp;&nbsp;&nbsp;&nbsp;print;<br>
}<br>
--snip--<br>
<br>
run like this ./tryit.pl file &gt; newfile<br>
<br>
If you haven't got perl - you can do the same job in awk I'm sure, but I'd have to look that up...<br>
<br>
Mike<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
I get the same problem but have foud that ted will normally open the file. Another alternative may be to use a PC with Microsoft Word, the 'open' option allows the setting up of FTP locations which can be used to access files on other machines. <p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>
 
Are you sure about the control characters that are being used to delimit the file? It could be there aren't any in there, or there are, and they aren't what you expect.<br>
<br>
Try doing a &quot;cat -vet filename.txt ¦ pg&quot; This will tell 'cat' to display non-printable control characters, display Tab as ^I, formfeed as ^L, and end of line with $. eg:<br>
<br>
1$<br>
2^M$<br>
3$<br>
4$<br>
5$<br>
$<br>
<br>
File has a blank line at the end, and a ^M after line 2.<br>
<br>
If you confirm that you need ^M etc, then you'll need to create a small shell script in vi to run your sed command. When you do, remember that after typing Ctrl+V, you need to then type the control character you need, ie, Ctrl+M, not just the M on it's own.<br>
<br>
Hope this helps.
 
from an email conversation with shodan81 the following perl script does the job<br>
<br>
--snip--<br>
#!/local/bin/perl<br>
<br>
while(&lt;&gt;){<br>
s/\r/\n/go;<br>
print;<br>
}<br>
--snip--<br>
<br>
Difference from first version is \r rather than \m<br>
<br>
-ml<br>
<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top