sed question - open, write same file
I'd like to open, edit, write the same file using sed --all in a single line. If I do this:
sed 's/foo/bar/' /tmp/myfile
the contents of the file are displayed with the modification. I've tried
sed 's/foo/bar/' </tmp/myfile> /tmp/myfile
cat /tmp/myfile | sed 's/foo/bar/' >/tmp/myfile
but I typically end up with an empty file.
I read about the x, hold buffer --but it didn't fully make sense to me.
Thanks a bunch for the help.