Append text error?

Sup guys, today I tried to append a string from my text by asking the user to input and change the specific text they wanna append.
The problem is that, the code looks logically correct, but when I run it there's an error somewhere.
Can anyone identify for me?

echo "Search data"
read current
echo "Data to be changed"
read change
sed "/$current/$change" file.txt > file1.txt && mv file1.txt file.txt

My file.txt contains the following.

sampleA:Alex:30:10:10
sampleB1:Tracy:2.56:8:4
sampleZ5:Darryl:3:50:7

It gives me an error.
sed: -e expression #1, char 8: extra characters after command.

So let's say I want to change Alex name to Bryan is this the way to do it?

I have not had lunch yet, but I am guessing that you are not telling sed what to do. Perhaps (note the s)

sed "s/$current/$change" file.txt > file1.txt
1 Like

Sorry for the trouble man but I would like to keep the same file(file.txt) instead of saving it to a new file(file1.txt) so thats why I got the && mv command.

Your problem is still with the "sed":

sed "s/$current/$change/g" ...
2 Likes

Ahh it work perfectly thx!!