Single line file editing command?

Hello everyone. I have been reading a lot about the various different text editors at my disposal through Unix, but I just can't seem to close the deal for what I am trying to do. Is there a way to issue a single line command to edit a file where pattern=x, and do it non-destructively AND in-place? It is my understanding that sed does not do in-place edits, and I seem to be unable to use ed as a single-line command. Any help would be appreciated. Thank you.

Not sure what kind of editing you want to do, but for simple find and replace, sed with the -i switch can perform that function in place.

sed -i.orig -e 's/pattern1/pattern2/g'

The -i.orig will make the change in the file and make a copy of the original file with the .orig extension in case you need to revert to the original file.

Hope this helps steer you in the right direction.