sed tee, “Search, replace, and commit back.”


If you are a command-line *nix guy like I am, chances are good you have come cross a point where you wanted to replace a certain pattern in a file and write the change(s) back to the file. If you haven’t already figured it out, sed(1) and tee(1) will help you do that in a single line.

ayaz$ sed 's/pattern/replace/g' file | tee file

Advertisements

2 thoughts on “sed tee, “Search, replace, and commit back.”

  1. Pingback: Re: sed tee, “Search, replace, and commit back.” « Libel

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s