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
Code language: Bash (bash)

Option 2: use > with sed

sed 's/Hello/Hi/g' file-name > file
Code language: Bash (bash)

Option 3: use sed with -i option

sed -i 's/Hello/Hi/g' file-name
Code language: Bash (bash)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments