Lets say you want to run a sed command, but you want it to save a backup before editing a file.

Here is how you do that:

This will take filename1 and apply the SED EXPRESSION to it, but it will make an original untouched copy of filename1 to filename1.bak. Why .bak? well because thats what we told it to do with -i.bak.

Here is an example:

Now run this:

End result:

Here is our backup (notice now its .backup, because thats what I put after the -i)


Leave a Reply

Your email address will not be published. Required fields are marked *