Active Oldest Votes. Improve this answer. Dessa Simpson 1, 1 1 gold badge 13 13 silver badges 30 30 bronze badges. Gilles Quenot Gilles Quenot k 33 33 gold badges silver badges bronze badges. And to get it to write back to the file without printing the contents of the file? Note that both assume GNU sed. That's not standard sed syntax and won't work with any other sed implementation. I had trouble getting this to work for me because I was using a different delimiter. How does it apply ONLY to the first match?
This adds the text after every match, for me. Show 9 more comments. Stephane Chazelas Stephane Chazelas 5, 2 2 gold badges 28 28 silver badges 29 29 bronze badges.
AbandonedCart, in shells of the Bourne, csh or rc family, ' The only exception that I know is the fish shell. Terminal on MacOS and subsequently a script run in terminal is also an exception, apparently.
I found alternate syntax, but thanks anyway. AbandonedCart, that's something else. That makes my statement about it being portable incorrect for the one line variant. I'll ask the opengroup for confirmation if it's indeed a non-conformance or a misinterpretation of the standard on my part. I had so many problems with different versions of sed that I tried the printf This works like charm! I love it! Breezer Breezer 3 3 silver badges 10 10 bronze badges.
Thank you for the answer! Notify me of followup comments via e-mail. All rights reserved Terms of Service. This article is part of the on going Unix sed command tutorial series. Sed provides lot of commands to perform number of operations with the lines in a file. Ramesh Natarajan December 10, , pm. Balast July 3, , pm. Hi, How to insert content of file1 on the top of the file2, file3, file4, etc in same directory?
Manish November 4, , am. Hi How I can escape Back slashes in sed. Anonymous December 1, , am. Balaji May 6, , am. David Liontooth June 18, , am. I nominate for the best set of sed instructions on the Internet. I want to change the first line of a csv file into lower case. How to do that. Steve August 27, , pm. Carlos Luna November 3, , pm. Anyhow hope it helps. Steve Bennett February 5, , pm. Nidhi March 29, , am.
Reynold May 18, , pm. Is variable substitution supported with the sed insert command? Learn more. How to insert multiple lines with sed Ask Question. Asked 6 years, 1 month ago. Active 3 years ago. Viewed 45k times. Improve this question. Add a comment. Active Oldest Votes. Improve this answer.
Walter A Walter A 3 3 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook.
0コメント