When a filename is passed to sed, it usually prints to stdout. The -I option will cause sed to modify the contents of the file in place:
$ sed 's/PATTERN/replacement/' -i filename
For example, replace all three-digit numbers with another specified number in a file, as follows:
$ cat sed_data.txt
11 abc 111 this 9 file contains 111 11 88 numbers 0000
$ sed -i 's/\b[0-9]\{3\}\b/NUMBER/g' sed_data.txt
$ cat sed_data.txt
11 abc NUMBER this 9 file contains NUMBER 11 88 numbers 0000
The preceding one-liner replaces three-digit numbers only. \b[0-9]\{3\}\b is the regular expression used to match three-digit numbers. [0-9] is the range of digits from 0 to 9. The {3} string defines the count of digits. The backslash is used to give a special meaning for { and } and \b stands for a blank, the word boundary marker.
It's a useful practice to first try the sed command without -i to make sure your regex is correct. After you are satisfied with the result, add the -i option to make changes to the file. Alternatively, you can use the following form of sed:
sed -i .bak 's/abc/def/' file
In this case, sed will perform the replacement on the file and also create a file called file.bak, which contains the original contents.