regex - How to use sed to replace partial of a find -


The

A few lines in file this looks like:

  LOB ( "VALUE") as SECUREFILE "L_MS_WRKNPY_VALUE_0000000011" store (LOB ( "INDEX_XML") SECUREFILE as shop "L_HRRPTRY_INDX_L_0000000011" ( 

what I can assume that it the "*" < / Code> String starts with a L_ and ends in the number of 10 characters.

I want for each line:

  1. Start with LOB (white location before LOB )
  2. P> change the last 10 characters with the variables.

    Whatever I manage, it is: cat / Tmp / out.log | sed 's / _ [0-9 _] * / $ NUM / g' & gt; /tmp/newout.log

    the required lines I run : grep "^ LOB" create_tables_clean.sql | Although I do not know how to combine both and what I want to do.

    "Post-text" itemprop = "text">
      sed -r / s (/ sLOB. * "L _. + _) ([0- 9] {10}) (" \ () \ 1 '$ myVar' \ 3 / ' 

    Change $ myVar with its own variable, obviously.

    Enter image details here

    I've created three capturing groups:

      (\ sLOB. * "L _. + _) # 10-digit ([0- 9] {10}) to catch everything Bicraan # 10 points (" \ () # catch the last "( 

    Only if the line (a predecessor to start with white space) LOB and includes the first capturing group matches" L. _ .
    then you place the first and third capturing group ( \ 1 'myVar' \ 3 ) while the second capturing group with its variable (only 10 numbers) to

    Your full call will look like this

      cat /tmp/out.log | SED -r / (. \ .of * "L _ + _." ([0-9] {10}) ("\ () / \ 1 '$ NUM' \ 3 / g '& gt; / tmp / newout log  

    (notice I g regex to -modifier, every event it added matches)


Comments