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.

3
  • Thanks, that works. Will this rewrite the entire file? If I can, I'd like to only write sometext because my file might be pretty big. Commented Aug 17, 2016 at 19:01
  • 1
    @aswine What do you mean by "only write sometext"? It's inserting text; everything after it will now be a bit later in the file. It might depend on your filesystem, but whatever method you pick, you will probably be rewriting the whole file from that point all the way to the end. Commented Aug 17, 2016 at 19:04
  • 1
    @aswine sed -i will just write to a temporary file then, when it's done, move that temporary file over the original. There aren't many ways around this no matter what tool you use. Commented Aug 17, 2016 at 19:05