Redirect sed to file




















Learn more. Asked 11 years, 9 months ago. Active 5 years, 2 months ago. Viewed 34k times. Improve this question. How come no one mentioned sponge? I guess the question was not sponge-worthy. Add a comment. Active Oldest Votes. Improve this answer. Nathan Kidd Nathan Kidd 2, 19 19 silver badges 22 22 bronze badges. Value of the parameter is backup extension to use, when it's empty string - no backup will be done.

On GNU sed the default value for -i is empty string. It's my life saver — Jianxin Gao. If you don't want to move copies around, you could use ed: ed file. Sed creates or truncates the given filename before reads the first input line and it writes all the matches to a file without closing and re-opening the file.

Sed reads a line and place it in a pattern buffer and writes the pattern buffer to the given output file according to the supplied commands. Thanks in advance…. I have a scenario like, Needs to content between 2 strings Begin and End ,after End i have some more lines i also needs to print next 4 lines from End.

I would lie if you can correct following shell. I prefer flexible , user can give the line numbers from and to , for selection from a file. With due Regards. Use -i edit in-place option in sed. Thanks sat. That's a really good explanation. Karoly people like you makes other people uncomfortable of asking questions on stack overflow Add a comment.

Active Oldest Votes. Improve this answer. Thx for the quick answer! Add a comment. Active Oldest Votes. It seems like you have two questions here Can I recover the file I overwrote? What's the best way to replace data in a file? Improve this answer. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked 9.



0コメント

  • 1000 / 1000