Below is my test script in which i am try to replace one of the line in script during runtime.

/home/xxx/test.sh

```
#!/bin/bash
SCRIPT_PATH=`pwd`/`basename $0`
username=admin
password='pass1234'

u="$(grep 'username' $SCRIPT_PATH | awk -F'=' '{ print $2 }')"
p="$(grep 'password' $SCRIPT_PATH | awk -F'=' '{ print $2 }')"

sed -i "s/user=/user="${u}"/3" "$SCRIPT_PATH"
sed -i "s/pass=/pass="${p}"/3" $SCRIPT_PATH

user=
pass=

```

Issue: the sed is actually replacing the search pattern here. I tried "3" at the end hoping it will target the 3rd occurance in the file, but that didn't working as expected.

I want to to replace the last user= and pass= with user=admin and pass='pass1234'

Any advice. Still trying.

OUTPUT i expect the file should changed to:

```
#!/bin/bash
SCRIPT_PATH=`pwd`/`basename $0`
username=admin
password='pass1234'

u="$(grep 'username' $SCRIPT_PATH | awk -F'=' '{ print $2 }')"
p="$(grep 'password' $SCRIPT_PATH | awk -F'=' '{ print $2 }')"

sed -i "s/user=/user="${u}"/3" "$SCRIPT_PATH"
sed -i "s/pass=/pass="${p}"/3" $SCRIPT_PATH

user=admin
pass='pass1234'

```