0

I searched here and found I could use sed to edit some text files. These are emlx files from Apple's Mail.app which has added some plist date. I want to remove the line

<?xml version="1.0" encoding="UTF-8"?>

and all following from the files and save the file.

This (almost) does what I want

sed -n '/<?xml version="1.0" encoding="UTF-8"?>/q;p myfile.emlx

Using a Mac, in Terminal I see the file written out having the lines edited out. Good. But I'm soft and don't know how to get sed to save the file. I'm happy to save to the original (I'm working from copies).

Apparently

-i

should do what I need. But it isn't. Please give me a clue! Then later I'll ask how to deal with a batch of 1500 files.

  • For macOs sed use: `sed -i '' '//d' myfile.emlx` – 0stone0 Apr 26 '21 at 11:04
  • Check the third code-block [on the linked answer](https://stackoverflow.com/a/5410784/5625547) – 0stone0 Apr 26 '21 at 11:36
  • Yes, I just read about the code I need on macOS so that's working, thanks. However what that code does is leave my file with the first line I wanted to delete (). Although this would work for my needs I expected the saved file to have had that line removed. – DaveGlasgow Apr 26 '21 at 11:38

0 Answers0