Help with find and Replace using sed

I have to update a paramater (dateMemLimit) present in a file, with a date (YYYYMMDD) equal to 5 days before the sysdate. The parameter will be in the following format.

dateMemLimit = 20091201

Please note the blank spaces present between 'dateMemLimit' &'=' and between '=' & '20091201'. I have to update this parameter everyday by invoking a script in cron. I managed to get the date value (which is equal to 5 days before the sysdate), but I am not sure how to replace the existing date value with the new one, that too without disturbing the blank spaces present in-between. Please help me to handle this, using 'sed'

 sed -e "s/\(dateMemLimit = \).*/\1$my_new_date/g" abc.txt

where $my_new_date will have the date

HTH,
PL

Thank you very much for ur reply. It worked. But now I am facing a different problem. The format of that parameter is like this now.

dateMemLimit<tab><spaces><tab>=<tab><spaces><tab>20091201

Moreover, its not necessarily '<tab><spaces><tab>'. It can take any sequence. I mean it can also be in the form of <space><space><tab>. As I am receiving this file from a different server everyday, I dont have control over it. Can you help me to handle this :frowning:

sed -e "s/\(dateMemLimit\s*=\s*\).*/\1$my_new_date/g" abc.txt

If you are not sure of the number of spaces then use the above

Alternatively if the format contains some additional text use .*?

HTH,
PL

Thank u very much boss. It worked :slight_smile: