<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>bash ubuntu on random thoughts</title><link>https://awesomeprogrammer.com/categories/bash-ubuntu/</link><description>Recent content in bash ubuntu on random thoughts</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Thu, 25 Jul 2013 00:00:00 +0000</lastBuildDate><atom:link href="https://awesomeprogrammer.com/categories/bash-ubuntu/index.xml" rel="self" type="application/rss+xml"/><item><title>Windows-1250 to utf-8 bash one-liner</title><link>https://awesomeprogrammer.com/blog/2013/07/25/windows-1250-to-utf-8-bash-one-liner/</link><pubDate>Thu, 25 Jul 2013 00:00:00 +0000</pubDate><guid>https://awesomeprogrammer.com/blog/2013/07/25/windows-1250-to-utf-8-bash-one-liner/</guid><description><![CDATA[<p>There was a time when I worked with non utf-8 coded files quite a lot. They were usually saved using Windows-1250 encoding and obviously I wanted them in utf-8. I think I don&rsquo;t need to tell you that you should probably use <code>iconv</code> for that, but there is also quite interesting tool called <code>sponge</code> that will allow you to pipe output of iconv to the very same file. In ubuntu it comes with packed called <code>moreutils</code> (also check out other apps it provides!). Install it with:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo apt-get install moreutils
</span></span></code></pre></div><p>Then in your <code>.bashrc</code> you can define something like:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#66d9ef">function</span> windows2utf<span style="color:#f92672">()</span> <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  iconv -f Windows-1250 -t utf-8 $1 | sponge $1
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Reload the file with <code>source .bashrc</code> and try out your new, handy function :).</p>
]]></description><content:encoded><![CDATA[<p>There was a time when I worked with non utf-8 coded files quite a lot. They were usually saved using Windows-1250 encoding and obviously I wanted them in utf-8. I think I don&rsquo;t need to tell you that you should probably use <code>iconv</code> for that, but there is also quite interesting tool called <code>sponge</code> that will allow you to pipe output of iconv to the very same file. In ubuntu it comes with packed called <code>moreutils</code> (also check out other apps it provides!). Install it with:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo apt-get install moreutils
</span></span></code></pre></div><p>Then in your <code>.bashrc</code> you can define something like:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#66d9ef">function</span> windows2utf<span style="color:#f92672">()</span> <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  iconv -f Windows-1250 -t utf-8 $1 | sponge $1
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Reload the file with <code>source .bashrc</code> and try out your new, handy function :).</p>
]]></content:encoded></item></channel></rss>