Reputation: 3605
I'm trying to delete a line from a file and update the file to reflect that. I'm running a bash command inside a python program. The line delete works on the terminal, but the file isn't updated.
subprocess.call("sed -e $d {}".format(self._path).split())
How can I update the file to not have this line anymore.
Upvotes: 0
Views: 53
Reputation: 10064
Should add the -i
flag to sed command to edit the file in-place.
On BSD's sed:
subprocess.call("sed -i '' -e $d {}".format(self._path).split())
On GNU's sed:
subprocess.call("sed -i -e $d {}".format(self._path).split())
Upvotes: 1