<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>File Descriptor on Amit Agarwal Linux Blog</title>
    <link>/tags/file-descriptor/</link>
    <description>Recent content in File Descriptor on Amit Agarwal Linux Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Tue, 12 Jun 2012 01:05:34 +0000</lastBuildDate>
    
	<atom:link href="/tags/file-descriptor/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>symlinks -delete all invalid soft links in Linux/Fedora</title>
      <link>/2012/06/12/symlinks-delete-invalid-soft-links-linuxfedora/</link>
      <pubDate>Tue, 12 Jun 2012 01:05:34 +0000</pubDate>
      
      <guid>/2012/06/12/symlinks-delete-invalid-soft-links-linuxfedora/</guid>
      <description>&lt;p&gt;First of all, install symlinks if it is not installed :&lt;/p&gt;
&lt;pre class=&#34;brush: bash; gutter: true; first-line: 1&#34;&gt;sudo yum install symlinks&lt;/pre&gt;
&lt;p&gt;and here is the description:&lt;/p&gt;
&lt;blockquote&gt;
&lt;dl&gt;
&lt;dt&gt;Description : The symlinks utility performs maintenance on &lt;a class=&#34;zem_slink&#34; title=&#34;Symbolic link&#34; href=&#34;http://en.wikipedia.org/wiki/Symbolic_link&#34; rel=&#34;wikipedia&#34; target=&#34;_blank&#34;&gt;symbolic links&lt;/a&gt;.&lt;/dt&gt;
&lt;dd&gt;Symlinks checks for symlink problems, including dangling symlinks&lt;/dd&gt;
&lt;dd&gt;which point to nonexistent files.  Symlinks can also automatically&lt;/dd&gt;
&lt;dd&gt;convert absolute symlinks to relative symlinks.&lt;/dd&gt;
&lt;dd&gt;&lt;/dd&gt;
&lt;dd&gt;Install the symlinks package if you need a program for maintaining&lt;/dd&gt;
&lt;dd&gt;symlinks on your system.&lt;/dd&gt;
&lt;/dl&gt;
&lt;/blockquote&gt;
&lt;p&gt;and the help for the same:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>faster bash operations on files with File Descriptors.</title>
      <link>/2011/06/11/faster-bash-operations-files-file-descriptors/</link>
      <pubDate>Sat, 11 Jun 2011 02:11:53 +0000</pubDate>
      
      <guid>/2011/06/11/faster-bash-operations-files-file-descriptors/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;I was &lt;a class=&#34;zem_slink&#34; title=&#34;Writing&#34; rel=&#34;wikipedia&#34; href=&#34;http://en.wikipedia.org/wiki/Writing&#34;&gt;writing&lt;/a&gt; a &lt;a class=&#34;zem_slink&#34; title=&#34;Bash (Unix shell)&#34; rel=&#34;homepage&#34; href=&#34;http://tiswww.case.edu/php/chet/bash/bashtop.html&#34;&gt;bash script&lt;/a&gt; that would do some operations and read and write to file. Seems that that was pretty simple with&lt;/p&gt;
&lt;div class=&#34;codecolorer-container text solarized-light&#34; style=&#34;overflow:auto;white-space:nowrap;width:550px;&#34;&gt;
  &lt;table cellspacing=&#34;0&#34; cellpadding=&#34;0&#34;&gt;
    &lt;tr&gt;
      &lt;td class=&#34;line-numbers&#34;&gt;
        &lt;div&gt;
          1&lt;br /&gt;2&lt;br /&gt;3&lt;br /&gt;4&lt;br /&gt;5&lt;br /&gt;
        &lt;/div&gt;
      &lt;/td&gt;
&lt;pre&gt;&lt;code&gt;  &amp;lt;td&amp;gt;
    &amp;lt;div class=&amp;quot;text codecolorer&amp;quot;&amp;gt;
      while read line&amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt; do&amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt; done&amp;lt;file
    &amp;lt;/div&amp;gt;
  &amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
  &lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;and then use redirection operations like “&amp;gt;” and “&amp;raquo;” to write to file. Done with the script pretty fast. So far so good, when I went for real life tests, no one was interested in using it, why? Simple, it was simply taking too long. The file was reading about 10K lines and writing about 50 lines and was taking about more than 10 minutes.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>tee to a file descriptor</title>
      <link>/2010/08/13/tee-to-a-file-descriptor/</link>
      <pubDate>Fri, 13 Aug 2010 03:22:44 +0000</pubDate>
      
      <guid>/2010/08/13/tee-to-a-file-descriptor/</guid>
      <description>&lt;p&gt;tee to a file descriptor&lt;/a&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ tee &amp;gt;&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;cat &lt;span class=&#34;p&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&#34;c1&#34;&gt;#8211; &amp;gt;&amp;amp;2)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;the tee command does fine with file names, but not so much with file descriptors, such as &amp;amp;2. This uses process redirection to tee to the specified descriptor.&lt;/p&gt;
&lt;p&gt;In the sample output, it&amp;rsquo;s being used to tee to stderr, which is connected with the terminal, and to wc -l, which is also outputting to the terminal. The result is the output of bash –version followed by the linecount&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>coproc help - a new feature in bash</title>
      <link>/2010/05/10/coproc-feature-bash/</link>
      <pubDate>Mon, 10 May 2010 15:07:45 +0000</pubDate>
      
      <guid>/2010/05/10/coproc-feature-bash/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;&lt;div class=\&#34;zemanta-img\&#34;&gt; 
&lt;div&gt;
  &lt;dl class=\&#34;wp-caption alignright\&#34;&gt; &lt;dt class=\&#34;wp-caption-dt\&#34;&gt;&lt;a href=\&#34;http://commons.wikipedia.org/wiki/Image:Bash_demo.png\&#34;&gt;&lt;img title=\&#34;Screenshot of a Bash 3.1 session demonstrating...\&#34; src=\&#34;http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/300px-Bash_demo.png\&#34; alt=\&#34;Screenshot of a Bash 3.1 session demonstrating...\&#34; /&gt;&lt;/a&gt;&lt;/dt&gt; &lt;dd class=\&#34;wp-caption-dd zemanta-img-attribution\&#34;&gt;Image via &lt;a href=\&#34;http://commons.wikipedia.org/wiki/Image:Bash_demo.png\&#34;&gt;Wikipedia&lt;/a&gt;&lt;/dd&gt; &lt;/dl&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;In the &amp;lt;a class=&amp;quot;zem_slink freebase/en/bash&amp;quot; title=&amp;quot;Bash&amp;quot; rel=&amp;quot;homepage&amp;quot; href=&amp;quot;http://tiswww.case.edu/php/chet/bash/bashtop.html&amp;quot;&amp;gt;bash&lt;/a&gt; version 4.0, there is a new concept called coproc. This is very useful for some of the daily tasks.&lt;/p&gt;
&lt;p&gt;co-&amp;lt;a class=&amp;quot;zem_slink freebase/guid/9202a8c04000641f800000000005a409&amp;quot; title=&amp;quot;Process (computing)&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Process_%28computing%29&amp;quot;&amp;gt;process&lt;/a&gt; starts a process in the background, optionally with a NAME, with which other processes can communicate. This can be a very &amp;lt;a class=&amp;quot;zem_slink freebase/en/substitute_good&amp;quot; title=&amp;quot;Substitute good&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Substitute_good&amp;quot;&amp;gt;good substitution&lt;/a&gt; for &amp;lt;a class=&amp;quot;zem_slink freebase/guid/9202a8c04000641f800000000048fac5&amp;quot; title=&amp;quot;Pipeline (Unix)&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Pipeline_%28Unix%29&amp;quot;&amp;gt;pipes&lt;/a&gt; in lots of cases. You can learn more about coproc in the link below:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>prepend to a file with sponge from moreutils</title>
      <link>/2010/03/16/prepend-to-a-file-with-sponge-from-moreutils/</link>
      <pubDate>Tue, 16 Mar 2010 02:25:42 +0000</pubDate>
      
      <guid>/2010/03/16/prepend-to-a-file-with-sponge-from-moreutils/</guid>
      <description>&lt;p&gt;&amp;lt;a href=&amp;quot;http://bashcurescancer.com/prepend-to-a-file-with-sponge-from-moreutils.html&amp;quot;&amp;gt;A few weeks I wrote about a tool, which helps you easily prepend to a file. I submitted prepend to moreutils and Joey was kind enough to point out this could be done with `sponge&amp;amp;#8217;.? sponge reads standard input and when done, writes it to a file:&lt;br&gt;
Probably the most general …&lt;/a&gt;&amp;lt;h6 class=&amp;quot;zemanta-related-title&amp;quot;&amp;gt;Related articles by Zemanta&lt;/h6&gt; &amp;lt;ul class=&amp;quot;zemanta-article-ul&amp;quot;&amp;gt; &amp;lt;li class=&amp;quot;zemanta-article-ul-li&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://helpdeskgeek.com/linux-tips/crontab-howto-tutorial-syntax/&amp;quot;&amp;gt;Automating Tasks in Linux Using Crontab&lt;/a&gt; (helpdeskgeek.com)&lt;/li&gt; &amp;lt;li class=&amp;quot;zemanta-article-ul-li&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.slideshare.net/progrium/sxsw-evented-web&amp;quot;&amp;gt;How WebHooks Will Make Us All Programmers&lt;/a&gt; (slideshare.net)&lt;/li&gt; &amp;lt;li class=&amp;quot;zemanta-article-ul-li&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://almirkaric.com/2010/01/07/debugging-python-multiprocessing/&amp;quot;&amp;gt;Debugging python (multi)processing&lt;/a&gt; (almirkaric.com)&lt;/li&gt; &amp;lt;li class=&amp;quot;zemanta-article-ul-li&amp;quot;&amp;gt;&amp;lt;a href=&amp;quot;http://www.slideshare.net/royzimmer/you-can-do-it-start-using-perl-to-handle-your-voyager-needs&amp;quot;&amp;gt;You Can Do It! Start Using Perl to Handle Your Voyager Needs&lt;/a&gt; (slideshare.net)&lt;/li&gt; &lt;/ul&gt; &amp;lt;div class=&amp;quot;zemanta-pixie&amp;quot;&amp;gt;&amp;lt;a class=&amp;quot;zemanta-pixie-a&amp;quot; title=&amp;quot;Reblog this post [with Zemanta]&amp;quot; href=&amp;quot;http://reblog.zemanta.com/zemified/b2b2afad-1679-46ab-831c-90ae0cc4d30f/&amp;quot;&amp;gt;&amp;lt;img class=&amp;quot;zemanta-pixie-img&amp;quot; src=&amp;quot;http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b14.png&amp;quot; alt=&amp;quot;Reblog this post [with Zemanta]&amp;quot; /&amp;gt;&lt;/a&gt;&amp;lt;span class=&amp;quot;zem-script more-related more-info pretty-attribution paragraph-reblog&amp;quot;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>
