[vox-tech] Problems with missing 'missing' file

Rick Moen rick at linuxmafia.com
Wed Jun 22 23:17:35 PDT 2011


Quoting Shwaine (shwaine at shwaine.com):

> Assuming that the \r is actually carriage return (and not a literal string 
> consisting of backslash and the letter r) and that this was originally an 
> older Mac formated file, you probably don't want to remove \r.

I actually meant exactly what I typed, i.e., the backslash as an escape,
followed by a character 'r'.  That's the way you refer to an ASCII 13
carriage return control character in vim search strings.  Line feed
would be \n.  Attempt to insert an actual CR into a vim ex-mode search
string, and you won't get the result you had in mind.

Whether that's specifically what the original poster needed, dunno.  I
really don't remember _precisely_ what he said at this point, and don't
want to spend time looking it up.  I recall him saying that he had some
files with spurious embedded CRs and needed to remove him so related
software can build, hence wanted to use a canned utility for the
purpose.  My point was that, regardless of whether you think you want to
strip spurious CRs or spurious LFs or other such junk from a
modest-sized text file, ex-mode search & replace in vim is often the
most pragmatic method, because, even if you screw up the search, you can
trivially undo your change and try again differently.


> Older Mac files only have a carriage return to mark the end of line
> and do not have a line feed (\n, the end-of-line delimiter on
> Unix/Linux). So if you remove the carriage returns on an old Mac file,
> you end up with one very long line.

As I said upthread, and I said again above, the good thing about
attempting such a repair operation in vim is that, if you guess wrong
about what to do, or implement it badly, you can mumble 'Oops!', hit u
for undo, and you're right back and can get it right on Round Two.

> Better to check if there are line feeds....

No, better to just try out what you think is needed, and if you fumbled
it, undo, try again two seconds later.  Faster, gets the problem out of
the way.  Not worth the time to even remember all the antediluvian crap
about 'Old Mac files terminate ASCII lines with CR only, other Unixes
terminates ASCII lines with LF, DOS/Windows terminates ASCII lines with
CR LF.'  I'd reclaim those neurons for something actually useful if I
could.

The only slow bit is arguing with obsessives on mailing lists.  ;->



More information about the vox-tech mailing list