{"id":2709,"date":"2019-10-10T22:59:53","date_gmt":"2019-10-10T22:59:53","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=2709"},"modified":"2019-10-10T23:00:22","modified_gmt":"2019-10-10T23:00:22","slug":"remove-spaces-in-text-in-bash","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/remove-spaces-in-text-in-bash\/","title":{"rendered":"Remove spaces in string in bash variable"},"content":{"rendered":"\n<p>There are multiple way to remove spaces, <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Variable a contains the following<br>a=\"Hello World   !\"<\/pre>\n\n\n\n<p><strong>echo<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">echo ${a\/\/ \/}<\/pre>\n\n\n\n<p><strong>Sed<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">echo $a | sed \"s\/\\ \/\/g\"<\/pre>\n\n\n\n<p><strong>tr<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tr -d ' ' &lt;&lt;&lt;\"$a\"<\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">echo $a | tr -d ' ' <\/pre>\n\n\n\n<p>Returned output<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">HelloWorld!<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There are multiple way to remove spaces, # Variable a contains the followinga=&#8221;Hello World !&#8221; echo echo ${a\/\/ \/} Sed echo $a | sed &#8220;s\/\\ \/\/g&#8221; tr tr -d &#8216; &#8216; &lt;&lt;&lt;&#8220;$a&#8221; or echo $a | tr -d &#8216; &#8216; &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/remove-spaces-in-text-in-bash\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[211,757,759,758],"class_list":["post-2709","post","type-post","status-publish","format-standard","hentry","category-linux","tag-bash","tag-echo","tag-spaces","tag-tr"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=2709"}],"version-history":[{"count":3,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2709\/revisions"}],"predecessor-version":[{"id":2712,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2709\/revisions\/2712"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=2709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=2709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=2709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}