Loading ...
Sorry, an error occurred while loading the content.
 

How to do this?

Expand Messages
  • Jerrygreat
    Hello, friends, I have a huge file like: dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100 logfile=./.log blocksize=8192 dbv
    Message 1 of 13 , Nov 21, 2008
      Hello, friends,
      I have a huge file like:

      dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100 logfile=./.log
      blocksize=8192
      dbv file=/sja8/appl/oracle/ship/undotbs.dbf feedback=100 logfile=./.log
      blocksize=8192
      dbv file=/sja7/appl/oracle/ship/tools.dbf feedback=100 logfile=./.log
      blocksize=8192
      dbv file=/sja7/appl/oracle/ship/dtuser_01.dbf feedback=100 logfile=./.log
      blocksize=8192
      ......

      how can I change it to like bleow by using one command line



      dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100
      logfile=./system01.log blocksize=8192
      dbv file=/sja8/appl/oracle/ship/undotbs.dbf feedback=100
      logfile=./undotbs.log blocksize=8192
      dbv file=/sja7/appl/oracle/ship/tools.dbf feedback=100 logfile=./tools.log
      blocksize=8192
      dbv file=/sja7/appl/oracle/ship/dtuser_01.dbf feedback=100
      logfile=./dtuser_01.log blocksize=8192
      .............


      Thank you very much

      Jerry
      --
      View this message in context: http://www.nabble.com/How-to-do-this--tp20627275p20627275.html
      Sent from the Vim - General mailing list archive at Nabble.com.


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • xulxer
      Hi, if you want to split the line in front of all logfile netries and join this bit with all blocksize entries on a new line on a unix box, you can do:
      Message 2 of 13 , Nov 21, 2008
        Hi,

        if you want to split the line in front of all logfile netries and join
        this bit with all blocksize entries on a new line on a unix box, you can do:

        %s~\(logfile.*\)\n\(.*\)~\r\1 \2~g

        I don't know if you have to use \n instead \r on windows.

        Kind regards

        Chris

        >
        >
        >Hello, friends,
        >I have a huge file like:
        >
        >dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100 logfile=./.log
        >blocksize=8192
        >dbv file=/sja8/appl/oracle/ship/undotbs.dbf feedback=100 logfile=./.log
        >blocksize=8192
        >dbv file=/sja7/appl/oracle/ship/tools.dbf feedback=100 logfile=./.log
        >blocksize=8192
        >dbv file=/sja7/appl/oracle/ship/dtuser_01.dbf feedback=100 logfile=./.log
        >blocksize=8192
        >......
        >
        >how can I change it to like bleow by using one command line
        >
        >
        >
        >dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100
        >logfile=./system01.log blocksize=8192
        >dbv file=/sja8/appl/oracle/ship/undotbs.dbf feedback=100
        >logfile=./undotbs.log blocksize=8192
        >dbv file=/sja7/appl/oracle/ship/tools.dbf feedback=100 logfile=./tools.log
        >blocksize=8192
        >dbv file=/sja7/appl/oracle/ship/dtuser_01.dbf feedback=100
        >logfile=./dtuser_01.log blocksize=8192
        >.............
        >
        >
        >Thank you very much
        >
        >Jerry
        >--
        >View this message in context: http://www.nabble.com/How-to-do-this--tp20627275p20627275.html
        >Sent from the Vim - General mailing list archive at Nabble.com.
        >
        >
        >
        --
        Bitte beachten Sie auch die Rückseite dieses Schreibens.

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • William Anderson
        Jerry, This should be pretty easy to accomplish with a simple regex. Something like %s#^ (dbv file=/sja./appl/oracle/ship/ ) (. + ) (.dbf .*logfile= )[^
        Message 3 of 13 , Nov 21, 2008
          Jerry,

          This should be pretty easy to accomplish with a simple regex. Something
          like

          %s#^\(dbv file=/sja./appl/oracle/ship/\)\(.\+\)\(.dbf .*logfile=\)[^
          ]*#\1\2\3./\2.log#

          Bill



          Jerrygreat wrote:
          >
          > Hello, friends,
          > I have a huge file like:
          >
          > dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100 logfile=./.log
          > blocksize=8192
          > dbv file=/sja8/appl/oracle/ship/undotbs.dbf feedback=100 logfile=./.log
          > blocksize=8192
          > dbv file=/sja7/appl/oracle/ship/tools.dbf feedback=100 logfile=./.log
          > blocksize=8192
          > dbv file=/sja7/appl/oracle/ship/dtuser_01.dbf feedback=100 logfile=./.log
          > blocksize=8192
          > ......
          >
          > how can I change it to like bleow by using one command line
          >
          >
          >
          > dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100
          > logfile=./system01.log blocksize=8192
          > dbv file=/sja8/appl/oracle/ship/undotbs.dbf feedback=100
          > logfile=./undotbs.log blocksize=8192
          > dbv file=/sja7/appl/oracle/ship/tools.dbf feedback=100 logfile=./tools.log
          > blocksize=8192
          > dbv file=/sja7/appl/oracle/ship/dtuser_01.dbf feedback=100
          > logfile=./dtuser_01.log blocksize=8192
          > .............
          >
          >
          > Thank you very much
          >
          > Jerry


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • StarWing
          my idea, combine xulxer and william s ... 1 2 3 r 4./ 2.log 5#g On 11ÔÂ22ÈÕ, ÉÏÎç6ʱ09·Ö, William Anderson ...
          Message 4 of 13 , Nov 21, 2008
            my idea, combine xulxer and william's

            :%s#\(/oracle/ship/\)\(.*\)\(.dbf .*\)\(logfile=\).\{-}\n\(.*\)#
            \1\2\3\r\4./\2.log \5#g

            On 11月22日, 上午6时09分, William Anderson <whand...@...>
            wrote:
            > Jerry,
            >
            > This should be pretty easy to accomplish with a simple regex. Something
            > like
            >
            > %s#^\(dbv file=/sja./appl/oracle/ship/\)\(.\+\)\(.dbf .*logfile=\)[^
            > ]*#\1\2\3./\2.log#
            >
            > Bill
            >
            > Jerrygreat wrote:
            >
            > > Hello, friends,
            > > I have a huge file like:
            >
            > > dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100 logfile=./.log
            > > blocksize=8192
            > > dbv file=/sja8/appl/oracle/ship/undotbs.dbf feedback=100 logfile=./.log
            > > blocksize=8192
            > > dbv file=/sja7/appl/oracle/ship/tools.dbf feedback=100 logfile=./.log
            > > blocksize=8192
            > > dbv file=/sja7/appl/oracle/ship/dtuser_01.dbf feedback=100 logfile=./.log
            > > blocksize=8192
            > > ......
            >
            > > how can I change it to like bleow by using one command line
            >
            > > dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100
            > > logfile=./system01.log blocksize=8192
            > > dbv file=/sja8/appl/oracle/ship/undotbs.dbf feedback=100
            > > logfile=./undotbs.log blocksize=8192
            > > dbv file=/sja7/appl/oracle/ship/tools.dbf feedback=100 logfile=./tools.log
            > > blocksize=8192
            > > dbv file=/sja7/appl/oracle/ship/dtuser_01.dbf feedback=100
            > > logfile=./dtuser_01.log blocksize=8192
            > > .............
            >
            > > Thank you very much
            >
            > > Jerry
            >
            >
            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Cesar Romani
            ... logfile=./.log ... logfile=./tools.log ... Regards, Cesar --~--~---------~--~----~------------~-------~--~----~ You received this message from the
            Message 5 of 13 , Nov 21, 2008
              StarWing wrote:
              > my idea, combine xulxer and william's
              >
              > :%s#\(/oracle/ship/\)\(.*\)\(.dbf .*\)\(logfile=\).\{-}\n\(.*\)#
              > \1\2\3\r\4./\2.log \5#g
              >
              > On 11月22日, 上午6时09分, William Anderson <whand...@...>
              > wrote:
              >> Jerry,
              >>
              >> This should be pretty easy to accomplish with a simple regex. Something
              >> like
              >>
              >> %s#^\(dbv file=/sja./appl/oracle/ship/\)\(.\+\)\(.dbf .*logfile=\)[^
              >> ]*#\1\2\3./\2.log#
              >>
              >> Bill
              >>
              >> Jerrygreat wrote:
              >>
              >>> Hello, friends,
              >>> I have a huge file like:
              >>> dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100 logfile=./.log
              >>> blocksize=8192
              >>> dbv file=/sja8/appl/oracle/ship/undotbs.dbf feedback=100 logfile=./.log
              >>> blocksize=8192
              >>> dbv file=/sja7/appl/oracle/ship/tools.dbf feedback=100 logfile=./.log
              >>> blocksize=8192
              >>> dbv file=/sja7/appl/oracle/ship/dtuser_01.dbf feedback=100
              logfile=./.log
              >>> blocksize=8192
              >>> ......
              >>> how can I change it to like bleow by using one command line
              >>> dbv file=/sja7/appl/oracle/ship/system01.dbf feedback=100
              >>> logfile=./system01.log blocksize=8192
              >>> dbv file=/sja8/appl/oracle/ship/undotbs.dbf feedback=100
              >>> logfile=./undotbs.log blocksize=8192
              >>> dbv file=/sja7/appl/oracle/ship/tools.dbf feedback=100
              logfile=./tools.log
              >>> blocksize=8192
              >>> dbv file=/sja7/appl/oracle/ship/dtuser_01.dbf feedback=100
              >>> logfile=./dtuser_01.log blocksize=8192
              >>> .............
              >>> Thank you very much
              >>> Jerry
              >>
              > >
              >
              >

              :g/logfile/s//\r&/ | normal J

              Regards,
              Cesar

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • Tony Mechelynck
              ... In all versions of Vim, you _match_ a line break with n in the first half of a :subst command, you _insert_ one with r in the second half. This means
              Message 6 of 13 , Nov 21, 2008
                On 21/11/08 23:05, xulxer wrote:
                > Hi,
                >
                > if you want to split the line in front of all logfile netries and join
                > this bit with all blocksize entries on a new line on a unix box, you can do:
                >
                > %s~\(logfile.*\)\n\(.*\)~\r\1 \2~g
                >
                > I don't know if you have to use \n instead \r on windows.
                >
                > Kind regards
                >
                > Chris

                In all versions of Vim, you _match_ a line break with \n in the first
                half of a :subst command, you _insert_ one with \r in the second half.

                This means that one silly way to count lines (by replacing line breaks
                with themselves) is

                :%s/\n/\r/


                Best regards,
                --
                The Heineken Uncertainty Principle:
                You can never be sure how many beers you had last night.

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Agathoklis D. Hatzimanikas
                ... While regular expressions can do wonders, here is yet another way to solve your problem using VimL: let line = 1 while line
                Message 7 of 13 , Nov 23, 2008
                  On Fri, Nov 21, at 02:45 StarWing wrote:
                  >
                  > my idea, combine xulxer and william's
                  >
                  > :%s#\(/oracle/ship/\)\(.*\)\(.dbf .*\)\(logfile=\).\{-}\n\(.*\)#
                  > \1\2\3\r\4./\2.log \5#g


                  While regular expressions can do wonders, here is yet
                  another way to solve your problem using VimL:


                  let line = 1
                  while line < line('$')
                  let fline = split(getline(line))[:2]
                  let logfile = fnamemodify(fline[1], ":t:r")
                  call setline(line, join(fline))
                  call setline((line + 1), 'logfile=./'.logfile.'.log '.getline((line + 1)))
                  let line += 2
                  endwhile

                  Regards,
                  Ag.

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • vimlover
                  Hello, I have hundreds of rows in a files like: ALTER TABLE PCDTST . ACCOUNTINGSTATUS ADD CONSTRAINT PK_ACCOUNTINGSTATUS PRIMARY KEY ( ACCOUNTINGSTATUS )
                  Message 8 of 13 , Mar 1, 2009
                    Hello,

                    I have hundreds of rows in a files like:

                    ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                    "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS") USING INDEX PCTFREE
                    10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST
                    GROUPS 1) TABLESPACE "PESDBO_INDEXES" LOGGING ENABLE ;

                    how can I change to: (just delet 'USING' clause till ';' in each line)

                    ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                    "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS");

                    Thank you
                    vimlover

                    --
                    View this message in context: http://www.nabble.com/How-to-do-this--tp22274905p22274905.html
                    Sent from the Vim - General mailing list archive at Nabble.com.


                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_use" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • andalou
                    ... Regards, Cesar --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist. For more information, visit
                    Message 9 of 13 , Mar 1, 2009
                      On Mar 1, 11:46 am, vimlover <dawangsh...@...> wrote:
                      > Hello,
                      >
                      > I have hundreds of rows in a files like:
                      >
                      > ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                      > "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS") USING INDEX PCTFREE
                      > 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST
                      > GROUPS 1) TABLESPACE "PESDBO_INDEXES" LOGGING ENABLE ;
                      >
                      > how can I change to: (just delet 'USING' clause till ';' in each line)
                      >
                      > ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                      > "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS");
                      >
                      > Thank you
                      > vimlover
                      >
                      > --
                      > View this message in context:http://www.nabble.com/How-to-do-this--tp22274905p22274905.html
                      > Sent from the Vim - General mailing list archive at Nabble.com.

                      :%s/ USING.*/

                      Regards,
                      Cesar
                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_use" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • StarWing
                      ... maybe ... or ... you can choose one for try... --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist.
                      Message 10 of 13 , Mar 1, 2009
                        > I have hundreds of rows in a files like:
                        >
                        > ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                        > "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS") USING INDEX  PCTFREE
                        > 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1  FREELIST
                        > GROUPS 1) TABLESPACE "PESDBO_INDEXES" LOGGING ENABLE ;
                        >
                        > how can I change to: (just delet 'USING' clause till ';' in each line)
                        >
                        > ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                        > "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS");

                        maybe
                        :%s/USING \zs[^;]\ze;//g

                        or
                        :%s/USING \zs.\{-}\ze\s*;\s*$//g

                        you can choose one for try...
                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_use" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      • andalou
                        ... Regards, Cesar --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist. For more information, visit
                        Message 11 of 13 , Mar 1, 2009
                          On Mar 1, 12:40 pm, andalou <cesar.rom...@...> wrote:
                          > On Mar 1, 11:46 am, vimlover <dawangsh...@...> wrote:
                          >
                          >
                          >
                          > > Hello,
                          >
                          > > I have hundreds of rows in a files like:
                          >
                          > > ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                          > > "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS") USING INDEX PCTFREE
                          > > 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST
                          > > GROUPS 1) TABLESPACE "PESDBO_INDEXES" LOGGING ENABLE ;
                          >
                          > > how can I change to: (just delet 'USING' clause till ';' in each line)
                          >
                          > > ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                          > > "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS");
                          >
                          > > Thank you
                          > > vimlover
                          >
                          > > --
                          > > View this message in context:http://www.nabble.com/How-to-do-this--tp22274905p22274905.html
                          > > Sent from the Vim - General mailing list archive at Nabble.com.
                          >
                          > :%s/ USING.*/
                          >
                          > Regards,
                          > Cesar

                          I've forgotten something:
                          :%s/ USING.*/;

                          Regards,
                          Cesar
                          --~--~---------~--~----~------------~-------~--~----~
                          You received this message from the "vim_use" maillist.
                          For more information, visit http://www.vim.org/maillist.php
                          -~----------~----~----~----~------~----~------~--~---
                        • vimlover
                          Thank you all very much for help. Regards vimlover ... -- View this message in context: http://www.nabble.com/How-to-do-this--tp22274905p22276291.html Sent
                          Message 12 of 13 , Mar 1, 2009
                            Thank you all very much for help.
                            Regards
                            vimlover




                            StarWing wrote:
                            >
                            >
                            >
                            >> I have hundreds of rows in a files like:
                            >>
                            >> ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                            >> "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS") USING INDEX
                            >>  PCTFREE
                            >> 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1  FREELIST
                            >> GROUPS 1) TABLESPACE "PESDBO_INDEXES" LOGGING ENABLE ;
                            >>
                            >> how can I change to: (just delet 'USING' clause till ';' in each line)
                            >>
                            >> ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                            >> "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS");
                            >
                            > maybe
                            > :%s/USING \zs[^;]\ze;//g
                            >
                            > or
                            > :%s/USING \zs.\{-}\ze\s*;\s*$//g
                            >
                            > you can choose one for try...
                            > >
                            >
                            >

                            --
                            View this message in context: http://www.nabble.com/How-to-do-this--tp22274905p22276291.html
                            Sent from the Vim - General mailing list archive at Nabble.com.


                            --~--~---------~--~----~------------~-------~--~----~
                            You received this message from the "vim_use" maillist.
                            For more information, visit http://www.vim.org/maillist.php
                            -~----------~----~----~----~------~----~------~--~---
                          • Tony Mechelynck
                            ... Due to zs, the above won t remove the USING word itself. The command ... will delete everywhere from USING (included) to the _first_ following semicolon
                            Message 13 of 13 , Mar 2, 2009
                              On 01/03/09 18:41, StarWing wrote:
                              >
                              >> I have hundreds of rows in a files like:
                              >>
                              >> ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                              >> "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS") USING INDEX PCTFREE
                              >> 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST
                              >> GROUPS 1) TABLESPACE "PESDBO_INDEXES" LOGGING ENABLE ;
                              >>
                              >> how can I change to: (just delet 'USING' clause till ';' in each line)
                              >>
                              >> ALTER TABLE "PCDTST"."ACCOUNTINGSTATUS" ADD CONSTRAINT
                              >> "PK_ACCOUNTINGSTATUS" PRIMARY KEY ("ACCOUNTINGSTATUS");
                              >
                              > maybe
                              > :%s/USING \zs[^;]\ze;//g
                              >
                              > or
                              > :%s/USING \zs.\{-}\ze\s*;\s*$//g
                              >
                              > you can choose one for try...

                              Due to \zs, the above won't remove the USING word itself.

                              The command

                              :%s/\<USING\>\_.\{-}\ze;//g

                              will delete everywhere from USING (included) to the _first_ following
                              semicolon (excluded) regardless of how many or how few intervening
                              linebreaks there might be. USING must be present as a separate word:
                              something like HOUSING won't trigger the substitute.

                              Note the use of:
                              \< start of word
                              \> end of word
                              \_. anything including a linebreak
                              \{-} 0 or more, as few as possible
                              \ze the replaceable match ends here
                              g flag any number of times on a line

                              This assumes that quoted semicolons (which we must skip) won't happen
                              among the operands of USING.


                              Bestregards,
                              Tony.
                              --
                              Toilet Toupee, n.:
                              Any shag carpet that causes the lid to become top-heavy, thus
                              creating endless annoyance to male users.
                              -- Rich Hall, "Sniglets"

                              --~--~---------~--~----~------------~-------~--~----~
                              You received this message from the "vim_use" maillist.
                              For more information, visit http://www.vim.org/maillist.php
                              -~----------~----~----~----~------~----~------~--~---
                            Your message has been successfully submitted and would be delivered to recipients shortly.