Penguin

Differences between current version and previous revision of sedNotes.

Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History

Newer page: version 2 Last edited on Tuesday, February 13, 2007 1:03:17 pm by BenStaz
Older page: version 1 Last edited on Friday, December 29, 2006 6:12:30 pm by BenStaz Revert
@@ -2,4 +2,16 @@
  
 In sed, you don't have to use "/" to separate your statement. 
  
 sed 's/this/that/g' is the same as sed 's#this#that#g'. 
+  
+!How can I EDIT a file using sed?  
+  
+Use the ''-i'' switch.  
+This means that the file you supply to sed is overwritten with the changes made by sed.  
+If you don't want to lose the original file then after the ''-i'' switch you can add a backup extension.  
+  
+For example:  
+  
+*sed -i.bkp '1,2d' test.txt  
+  
+This will edit test.txt and the original file can be found in test.txt.bkp