<div dir="ltr">Hey, I need to do that in ruby so i can dump my unix2dos<div><br></div><div>Good Call Don.</div><div><br></div><div>Josh</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Aug 24, 2013 at 12:51 PM, Don Ellis <span dir="ltr"><<a href="mailto:don.ellis@gmail.com" target="_blank">don.ellis@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sometimes a text editor handles it just fine, but it can require<br>
actually looking at the documentation to find out how. In Vim, for<br>
example, the settings for filetype vs. fileformat may not be that<br>
obvious. Once you figure it out, it becomes drop dead easy.<br>
<br>
Some text editors can be scripted to batch process a list of files.<br>
Consider Perl to be one such editor; dos2unix etc can be written as a<br>
one-liner command line, though some safeguards might be a good idea<br>
for some users, as in this easily found (but somewhat verbose)<br>
example:<br>
<br>
<a href="http://www.obviously.com/tech_tips/dos2unix.html" target="_blank">http://www.obviously.com/tech_tips/dos2unix.html</a><br>
<br>
The active part in this example is:<br>
<br>
while( <INPUT> ) {<br>
s/\r\n$/\n/; # convert CR LF to LF<br>
print OUTPUT $_;<br>
}<br>
<br>
Another example is:<br>
<br>
<a href="http://www.wellho.net/resources/ex.php4?item=p210/cv" target="_blank">http://www.wellho.net/resources/ex.php4?item=p210/cv</a><br>
<br>
This example is really a one liner with comments detailing why it was<br>
written that way. It could as easily be issued on the command line<br>
without a saved script, using the -e switch, as in:<br>
<br>
perl -p -i.bak -e "s/foo/bar/; ... "<br>
<br>
(Camel 2, Chapter 6, on my favorite page in the whole book)<br>
The page on these switches (-p, -i, -e) explains why the first example<br>
can be rewritten with the magic input operator (<>), then why it can<br>
all be done on a single line.<br>
<br>
I do kind of like writing the one liner into a script (or alias, or<br>
shell function) so it's handy to get to and I don't have to remember<br>
the scripting details. Otherwise, using vim or your favorite editor is<br>
very handy too.<br>
<span class="HOEnZb"><font color="#888888"><br>
--Don Ellis<br>
</font></span><div class="im HOEnZb"><br>
<br>
On Sat, Aug 24, 2013 at 1:16 PM, Adam Tauno Williams<br>
<<a href="mailto:awilliam@whitemice.org">awilliam@whitemice.org</a>> wrote:<br>
><br>
> On Sat, 2013-08-24 at 12:19 -0400, Eric Beversluis wrote:<br>
> > I'm reading in Sobell, _Linux Commands..._, where he talks about<br>
> > unix2dos being necessary to send Linux text files to a Windows machine,<br>
> > and am confused.<br>
> ><br>
> > I think that I successfully send text files back and forth between<br>
> > Linux, Windows and Mac all the time without having to use this utility.<br>
> > Is this something that is obsolete in more modern operating systems? Or<br>
> > do the text editors now handle this automatically?<br>
><br>
> SOME editors handle it correctly. For example - notepad.exe does not,<br>
> but wordpad.exe will work just fine.<br>
><br>
> There really isn't and problems with the files, it just depends on what<br>
> you want to do.<br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
grlug mailing list<br>
<a href="mailto:grlug@grlug.org">grlug@grlug.org</a><br>
<a href="http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug" target="_blank">http://shinobu.grlug.org/cgi-bin/mailman/listinfo/grlug</a><br>
</div></div></blockquote></div><br></div>