This discussion is archived
3 Replies Latest reply: May 29, 2013 8:24 AM by 731089 RSS

complex shell script command

731089 Newbie
Currently Being Moderated
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 Expert
    Currently Being Moderated
    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
    Dude! Guru
    Currently Being Moderated
    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
    731089 Newbie
    Currently Being Moderated
    Thanks Guys for explanation .. i got it .. oracle forum rocks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points