Skip to content

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)

See also  How to run Shell Commands in a Kubernetes Cluster
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x