{"id":2255,"date":"2021-10-28T00:04:19","date_gmt":"2021-10-28T00:04:19","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=2255"},"modified":"2021-10-28T00:05:37","modified_gmt":"2021-10-28T00:05:37","slug":"how-to-add-suffix-to-lines-using-sed","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/how-to-add-suffix-to-lines-using-sed\/23939.html","title":{"rendered":"How To Add Suffix To Lines Using Sed"},"content":{"rendered":"<p>Hello again,<br \/>\nI am using on Windows XP many tools that originally I used in Linux: cat, sed, awk, head, tail, ls, wget.., and others. I found all those programs in the package UnxUtils<br \/>\nI am using &#8220;sed&#8221; many times just because it&#8217;s so useful for scripting.<br \/>\nHowever I have a problem: I don&#8217;t know how to add a suffix to lines using sed.<br \/>\nthe following script:<\/p>\n<p>cat file.txt | sed -e &#8220;s\/$\/suffix\/&#8221;<\/p>\n<p>will add the suffix AFTER each line so the result will look like:<br \/>\nline1<br \/>\nsuffix<br \/>\nline2<br \/>\nsuffix<br \/>\n&#8230;<br \/>\nI found a partial solution: cat file.txt | sed -e &#8220;s\/.$\/suffix\/&#8221; &#8211; it will add the suffix to the lines but will &#8220;eat&#8221; the last character from each line. That&#8221;s ok just as long as all the lines end in the same character (for example with a space)<\/p>\n<p>thanks<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":7},"question-category":[55],"question_tags":[],"class_list":["post-2255","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/2255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=2255"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=2255"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=2255"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=2255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}