{"id":274,"date":"2009-07-01T14:29:57","date_gmt":"2009-07-01T22:29:57","guid":{"rendered":"http:\/\/jim-zimmerman.com\/blog\/?p=274"},"modified":"2010-09-16T13:42:43","modified_gmt":"2010-09-16T20:42:43","slug":"sed-to-remove-first-or-last-character-in-a-string","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=274","title":{"rendered":"Sed to remove first or last character in a string."},"content":{"rendered":"<p>To remove the first character in a string:<br \/>\necho $STRING |sed &#8216;s\/.\\(.*\\)\/\\1\/&#8217;<\/p>\n<p>To remove the last character in a string:<br \/>\necho $STRING | sed &#8216;s\/\\(.*\\).\/\\1\/&#8217;<\/p>\n<p>To remove the last five characters in a string:<br \/>\necho $STRING | sed &#8216;s\/\\(.*\\)&#8230;..\/\\1\/&#8217;<\/p>\n<p>To remove all whitespace at the end of the line:<br \/>\necho $STRING | sed &#8216;s\/[ ]*$\/\/&#8217; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>To remove the first character in a string: echo $STRING |sed &#8216;s\/.\\(.*\\)\/\\1\/&#8217; To remove the last character in a string: echo $STRING | sed &#8216;s\/\\(.*\\).\/\\1\/&#8217; To remove the last five characters in a string: echo $STRING | sed &#8216;s\/\\(.*\\)&#8230;..\/\\1\/&#8217; To remove all whitespace at the end of the line: echo $STRING | sed &#8216;s\/[ ]*$\/\/&#038;#<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-274","post","type-post","status-publish","format-standard","hentry","category-documentation"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=274"}],"version-history":[{"count":3,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/274\/revisions"}],"predecessor-version":[{"id":409,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/274\/revisions\/409"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}