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. I have a string with special characters called