I have a string with special characters called /data/user/sam and I want to replace it with /data/sam and write it in a text file called sample.txt. I am able to do so but it keeps on appending the result in sample.txt on running the command again. It should replace it whole each time instead of appending.
Here is the snippet:-
sed 's/"\/data\/user\/sam"/"\/data\/sam"/g' sample.txt
Output in sample.txt on running twice
It should be:
on running as many times as user wants.