APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

add cr/lf carriage return line feed crlf


What is this stuff?

If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):



From: Jean-Pierre Radley <jpr@jpr.com>
Subject: Re: ADD CR/LF TO FILE
Date: Sat, 13 Oct 2001 00:48:30 GMT
References: <3bc73cbf$0$27639$724ebb72@reader2.ash.ops.us.uu.net>
<meLx7.3134$Y8.2325795@newssvr28.news.prodigy.com>
<9q81tu$n5aeh$1@ID-105888.news.dfncis.de> Bob Meyers propounded (on Fri, Oct 12, 2001 at 05:29:22PM -0700): | "Jim Mohr" <jrmohr@snet.net> wrote in message | news:meLx7.3134$Y8.2325795@newssvr28.news.prodigy.com... | | > "Dale Stover" <dale@stpsoft.com> wrote in message | > news:3bc73cbf$0$27639$724ebb72@reader2.ash.ops.us.uu.net... | > | > > HI! I am looking for a unix utility that will copy a file blocked | > > at 2048 | > > with no end-of-record delimitor to a file that has records of 2048 | > > plus a cr&lf. | > | > Install Perl and stuff like this becomes 1 and two liners. | | If you have a c compiler, one could write a small c program to do | it. I don't no where I got it (some SCO product) but for many years I | have had a little filter set called "addcr" and "rmcr". I always copy | it to any new server I do. It is just like cat but adds/removes a CR | to NL. If you don't find a solution, email me and I'll send it along.

Well, your little program is not what he needs, because the file he
has to work with has NO NEWLINES in the first place, so I suspect your
addcr/rmcr would not do what he wants, which is to add a NL/CR after
every 2048 bytes in the input.

Your addcr/rmcr, though, is all done by my one single file called cr+-:

        : cr+-
        # adds CRs if not present, strips them if present
        # note: if you just cat this file, you miss its essence
        # if you cat -v this file, you see the _real_ ^Ms in it
        sed '
        s-^M--g
        t
        s+$+^M+
        t
        '

-- 
JP
 


Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> add cr/lf carriage return line feed crlf ––>Re: ADD CR/LFTO FILE

1 comment



Increase ad revenue 50-250% with Ezoic





Fri Oct 17 13:56:36 2008: 4654   TonyLawrence

gravatar


In vi if you

:set ff=unix

and then write the file, you'll convert dos or mac file endings to unix.

Of course there's :set ff=dos and :set ff=mac too.

You can be more verbose if you wish:

:set fileformat=unix

Can't believe I never noticed this!

------------------------
Kerio Samepage


Have you tried Searching this site?

Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





Zawinski's Law: Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can. (Jamie Zawinski)





This post tagged: