Remove line based on string and put new line with parameter

Hi Folks,

I am new to ksh, i have informatica parameter file that i need to update everyday with shell script. i need your help updating this file with new parameters.

sample data
[GLOBAL]

[s\_m\_STG_TABLE1]
$$TABLE1_DATE=04-27-2011

[s\_m\_STG_TABLE2]
$$TABLE2_DATE=04-23-2011

[s\_m\_STG_TABLE3]
$$TABLE3_DATE=03-19-2011

.......Highligned are the values i need to update everyday..with another parameter coming from sqlplus statement. This values are dynamic and random because i wont load every table everyday. I need to update Highlithed value with parameter.

Try:

perl -i -pe 's/(?<=TABLE._DATE=).*/your_parameter/' file

Make a backup of your file first :wink:

1 Like

i dont perl utility to my profile..is there anyway.this can be done using sed and awk

Do you have GNU version of sed?

sed -i 's/\(TABLE._DATE=\).*/\1your_parameter/' file
1 Like

It solved my problem...

[---------- Post updated 05-26-11 at 07:49 AM ---------- Previous update was 05-25-11 at 03:50 PM ----------

it worked with double quotes

sed -i "s/\(TABLE._DATE=\).*/\1$parameter/" file