How to Save Sed Output Directly to a File


You have 3 options here:

Option 1: use tee with sed

sed 's/Hello/Hi/g' file-name | tee file

Option 2: use > with sed

sed 's/Hello/Hi/g' file-name > file

Option 3: use sed with -i option

sed -i 's/Hello/Hi/g' file-name