Re: SPLIT command in VI ?

From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 04/14/05

  • Next message: biomahui_at_gmail.com: "how to download files from a remote unix server to a windows machine"
    Date: Thu, 14 Apr 2005 13:12:47 GMT
    
    

    On comp.unix.questions, in <1113478473.995534.191960@l41g2000cwc.googlegroups.com>, "archilleswaterland@hotmail.com" wrote:
    >
    >
    > Hello,
    >
    > 123 4d3 ::(
    > 4fc 543 B:)
    >
    > Is there a spilt command in VI where I can specify split the third
    > group of characters on each line ?
    >
    > I have a huge file like this and need to get rid of the last column, so
    > in this case delete ::( and B:)
    >
    > Any suggestions ?
    >
    > THanks,
    > Archilles
    >

    Try this, Archilles:

    :%s/^\(... \)\(...\)\( .*$\)/\1\2/

    It could be a little simpler than that, but this
    way you can really see the principles involved.
    Those are regular expressions. There's a tutorial
    on my website:

    http://tinyurl.com/2aa6g

    Usually, for something like this, you'd use sed,
    the S tream ED itor. The commandline arguments are
    similar:

    sed -n 's/^\(... \)\(...\)\( .*$\)/\1\2/p' inputfile \
    > outputfile

    Check and make sure the output looks right, then:

    mv outputfile inputfile

    -----------------------------------------------------

    comp.editors is basically a vi/vim group. A bunch of
    vim fanatics pretty much dominate the group, but there
    are a lot of old pros there that still respect plain
    old vanilla vi, and they'll answer your questions if
    you persist in calling for a vi solution and are
    polite with the vim nuts.

    (Not that it isn't an excellent editor, but a lot of
    us are more-than-satisfied with vi. I'm using it here.

    AC


  • Next message: biomahui_at_gmail.com: "how to download files from a remote unix server to a windows machine"