3 Replies Latest reply: May 29, 2013 10:24 AM by user12035784 RSS

    complex shell script command

    user12035784
      HI Experts

      can anybody know what this complex shell script command is doing .. i know its looking for some character at some point but exact explanation will be good for learning.

      egrep "^.{292}[CFOPRA][EPR]$" dn.dat

      Thanks
        • 1. Re: complex shell script command
          Tommyreynolds-Oracle
          egrep "^.{292}[CFOPRA][EPR]$" dn.dat
          Is checking character position 293 for any of the characters C, F, O, P, R, or A followed by any of E, P, or R, followed by the end of the line.
          • 2. Re: complex shell script command
            Catch-22
            A simple example can often demonstrate how things work:
            # cat sample.dat
            xABCDE1
             xABCDE2
            ABCDE3
             ABCDE4
            xDBCEA5
             xDBCEA6
            
            # egrep "^.A" sample.dat
            xABCDE1
             ABCDE4
            
            Above matches lines that begin with any character followed by an "A".
            
            # egrep "^.{2}A" sample.dat
             xABCDE2
            
            Above matches lines that begin with any 2 characters followed by an "A".
            
            # egrep "^.{2}[AD]" sample.dat
             xABCDE2
             xDBCEA6
            
            Above matches lines that begin with any 2 characters followed by an "A" or D".
            
            # egrep "^.{6}[345]$" sample.dat
             ABCDE4
            xDBCEA5
            
            Above matches any lines ending with "3", "4" or "5",
            provided it's the 7th character.
            
            # egrep "^.{5}[345]$" sample.dat
            ABCDE3
            
            Above matches any lines ending with "3", "4" or "5",
            provided it's the 6th character.
            
            # egrep "^.{6}[EA][26]$" sample.dat
             xABCDE2
             xDBCEA6
            
            Above matches any lines ending with combinations of "E2, E6, A2, A6", 
            provided the combination starts at character position 7.
            {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
            • 3. Re: complex shell script command
              user12035784
              Thanks Guys for explanation .. i got it .. oracle forum rocks