I know I can do " sed 's/old/new/g' filename to make the change to standard output.... however, is there a way that it would save the change to the file instead of just showing to the screen?

Another question on ed, i know i can search by using /target/ , but for example i need to change one of the x to y in a file which contains 50 x there. How do i pick the specific x I am looking for and do the change only to that specific x? Can anyone please give a quick example?

1. Look up the > and >> output redirection (and < input redirection)

2. Most ed command can be prefixed with a count, something like say 20s/target/