Perl one liner in bash script not replacing hours and minutes [HH:MM]

Hi

I want to replace time stamp in the following line

PROCNAME.Merge.exchMon.CODE.T_QSTART        08:45              read

assuming the new time stamp is 09:45 ; the line is getting replaced as below

:45              read 

I'm trying to use the perl one liner in bash script

perl -pi -e 's/('$PROCNAME'.Merge.exchMon.'$CODE'.'$T_QSTART'.*)'$CURRENT_QSTART'(.*read)/$1'$NEW_QSTART'$2/g' $CONFIG

Can anyone please help me here with the correct perl one liner?

i'm not keen on using sed and i want to avoid temporary files

sed -i => illegal option error

OS version:

SunOS solvma1 5.11 11.4.9.5.0 i86pc i386 i86pc
perl -pi -e 's/('$PROCNAME'.Merge.exchMon.'$CODE'.'$T_QSTART'.*)'$CURRENT_QSTART'(.*read)/${1}'$NEW_QSTART'${2}/g' $CONFIG
3 Likes

Thanks a ton! it worked!! :slight_smile: :slight_smile:

The shell concatenates $1 and 09:45 so it becomes $109:45 in the perl code, and perl sees $109
With the braces it becomes ${1}09:45
The trailing /g (g option) is nonsense here; the attempt to redo the substitution will never succeed.

1 Like

Thank you for making it clear!:b: