Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • I tried with sed 's/BILL /BILLING /g' Example.txt but it didnt work for me as the file Example.txt is still having the value 'BILL' Commented Jul 3, 2015 at 9:09
  • I added a workaround for your strange version of sed. Awkward, but working. Commented Jul 3, 2015 at 9:22
  • Oh, and another hint: your regex notation tries to replace the string BILL , not BILL (note the trailing blank (` `)). If your file does not contain that blank, then the regex will not match and replace... Commented Jul 3, 2015 at 9:24
  • I'm sorry the space was my typo mistake.. i tried 's/BILL/BILLING/g' Example.txt > Exam.txt But the Exam.txt is blank Commented Jul 3, 2015 at 10:15
  • Yep, you cannot redirect the output of sed to the file you use as input because of how the utility works. That is why the -i flag was introduced which internally buffers the output. Without that flag being available you have to use the workaround I added to the answer. Commented Jul 3, 2015 at 10:36