Add text before and after matched string on the same line.

I have a file with many lines. Below I'm highlighting only those line that concerns me from the file.

....
drwxr-xr-x    4 user1   dba           20480 Feb 25 20:38 /tmp/10203/cust/01
....
drwxr-xr-x    4 user1   dba           20480 Feb 25 20:38 /tmp/10203/cust/01/logs/mtr
....
drwxr-xr-x    4 user1   dba           20480 Feb 25 20:38 /tmp/10203/cust/03/src/files
drwxr-xr-x    4 user1   dba           20480 Feb 25 20:38 /tmp/10203/cust
....

I requirement is to append this string <font color=yellow> and add this string </font> at the end of the found string on the same line.

Thus, if we consider "/tmp/10203/cust/01" the desired output should be changes to the line with the exact match.
<font color=yellow>drwxr-xr-x 4 user1 dba 20480 Feb 25 20:38 /tmp/10203/cust/01</font>

It should not affect the superset string like this one "drwxr-xr-x 4 user1 dba 20480 Feb 25 20:38 /tmp/10203/cust/01/logs/mtr"

I know how to add text before and after the matched string on new line but i do not know how to on the same line with the exact match.

Below is what i tried:

sed 's/\b\/tmp\/10203\/cust\/01\b/& <\/font>' filename

But it adds the text to a superset string i.e does not exact match.

Can you please suggest ?

Try

awk -v"PRFX=<font color=yellow>" -v"SUFX=</font>" '{sub ("^.*/tmp/10203/cust/01$", PRFX "&" SUFX)} 1' file
....
<font color=yellow>drwxr-xr-x    4 user1   dba           20480 Feb 25 20:38 /tmp/10203/cust/01</font>
....
drwxr-xr-x    4 user1   dba           20480 Feb 25 20:38 /tmp/10203/cust/01/logs/mtr
....
drwxr-xr-x    4 user1   dba           20480 Feb 25 20:38 /tmp/10203/cust/03/src/files
drwxr-xr-x    4 user1   dba           20480 Feb 25 20:38 /tmp/10203/cust
 ....

EDIT: ... and your approach, adapted:

sed 's/^.*\/tmp\/10203\/cust\/01$/<font color=yellow>&<\/font>/' file

The problem I face is that the match pattern comes from a variable thus using escape charecters becomes difficult and i get the below error:

sed 's/^.*/tmp/10203/cust/01$/<font color=yellow>&</font>/'  /app/test.html 
sed: -e expression #1, char 20: unknown option to `s'

Is it possible to overcome this ?

That was not mentioned in your specification. How about supplying a decent, complete problem description from the start?

Did you test the awk proposal? How far did it get you? With patterns supplied in variables?

As to your sed question: a simple look into the resp. documentation helps: info sed :

So - try e.g.

sed 's#^.*/tmp/10203/cust/01$#<font color=yellow>&</font>#' file

EDIT: or, in the variables' case,

$ PRFX='<font color=yellow>'
$ SUFX='</font>'
$ sed "s#^.*/tmp/10203/cust/01\$#${PRFX}&${SUFX}#" file

Be aware that with double quotes, you will / may need to escape "sed / regex special characters" like the $ sign, or others.