<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Newline on Amit Agarwal Linux Blog</title>
    <link>/tags/newline/</link>
    <description>Recent content in Newline on Amit Agarwal Linux Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Fri, 12 Jul 2013 01:24:19 +0000</lastBuildDate>
    
	<atom:link href="/tags/newline/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>create text tables from delimited files.</title>
      <link>/2013/07/12/create-text-tables-delimited-files/</link>
      <pubDate>Fri, 12 Jul 2013 01:24:19 +0000</pubDate>
      
      <guid>/2013/07/12/create-text-tables-delimited-files/</guid>
      <description>&lt;p&gt;To create simple text tables to paste in emails or to use in any other document where you want to show a table, here is something that you can use. There is a perl module which provides “&lt;strong&gt;tablify&lt;/strong&gt;“. And here is how to use it:&lt;/p&gt;
&lt;pre class=&#34;brush: shell; gutter: true; first-line: 1; highlight: [1]&#34;&gt;sudo yum install perl-Text-RecordParser&lt;/pre&gt;
&lt;p&gt;This will install a command “tablify” that you can use in number of ways. Here is a simple example to use it. You can read the man pages to see how you can use it.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>C program to get the ascii string from a string</title>
      <link>/2012/07/25/program-ascii-string-string/</link>
      <pubDate>Wed, 25 Jul 2012 06:16:12 +0000</pubDate>
      
      <guid>/2012/07/25/program-ascii-string-string/</guid>
      <description>&lt;figure style=&#34;width: 300px&#34; class=&#34;wp-caption alignright&#34;&gt;&lt;a href=&#34;http://commons.wikipedia.org/wiki/File:Printf.svg&#34; target=&#34;_blank&#34;&gt;&lt;img class=&#34;zemanta-img-inserted zemanta-img-configured&#34; title=&#34;Example diagram of the printf function in the ...&#34; src=&#34;http://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Printf.svg/300px-Printf.svg.png&#34; alt=&#34;Example diagram of the printf function in the ...&#34; width=&#34;300&#34; height=&#34;71&#34; /&gt;&lt;/a&gt;&lt;figcaption class=&#34;wp-caption-text&#34;&gt;Example diagram of the printf function in the C programming language (Photo credit: Wikipedia)&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Lot of times, you would like to get the complete string in hex or ascii format and if you are one of them then this is something that will be helpful for you 🙂&lt;/p&gt;
&lt;p&gt;Example output:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;lp-amita[d=~/bin]&amp;gt; ./ascii aamit&lt;br&gt;
String – aamit, Length – 5&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Convert string to hex.</title>
      <link>/2012/04/13/convert-string-hex/</link>
      <pubDate>Fri, 13 Apr 2012 03:39:54 +0000</pubDate>
      
      <guid>/2012/04/13/convert-string-hex/</guid>
      <description>&lt;p&gt;If you want to use snoop or &lt;a class=&#34;zem_slink&#34; title=&#34;Tcpdump&#34; href=&#34;http://www.tcpdump.org/&#34; rel=&#34;homepage&#34; target=&#34;_blank&#34;&gt;tcpdump&lt;/a&gt; with &lt;a class=&#34;zem_slink&#34; title=&#34;advanced search&#34; href=&#34;http://search.twitter.com/advanced&#34; rel=&#34;homepage&#34; target=&#34;_blank&#34;&gt;advanced search&lt;/a&gt; in the packet, then you would need to convert the string to hex string. For this, either you can use a web search and find some &lt;a class=&#34;zem_slink&#34; title=&#34;Web application&#34; href=&#34;http://en.wikipedia.org/wiki/Web_application&#34; rel=&#34;wikipedia&#34; target=&#34;_blank&#34;&gt;web application&lt;/a&gt; to do that or you can use a simple C program like this 🙂&lt;/p&gt;
&lt;pre class=&#34;brush: c; gutter: true; first-line: 1&#34;&gt;/*
* =====================================================================================
*
*       Filename:  ascii.c
*
*    Description:  ascii to dec
*
*        Version:  1.0
*        Ceated:  03/02/2012 12:08:49 PM
*       Revision:  none
*       Compiler:  gcc
*
*         Author:  Amit Agarwal (aka), amit.agarwal@roamware.com
*  Last modified: Thu Mar 08, 2012  08:47PM
*
* =====================================================================================
*/
void main (int argc, char **argv){
    int i=0;
    char a[200]=&#34;&#34;,b[200]=&#34;&#34;;
    printf(&#34;String - %s, Length - %d\n&#34;,argv[1],strlen(argv[1]));
    /*printf(&#34;%x\n 0x&#34;,argv[1]);*/
    while (i &amp;lt; strlen(argv[1])){
        /*printf(&#34;%c&#34;,argv[1][i]);*/
        sprintf(a,&#34;%s%x&#34;,a,argv[1][i]);
        /*printf(&#34;a=%s\n&#34;,a);
        printf(&#34;b=%s\n&#34;,b);*/
        sprintf(b,&#34;%s%d&#34;,b,argv[1][i]);
        i++;
    }
    printf (&#34;\n&#34;);
    printf (&#34;String : %s\n&#34;,argv[1]);
    printf (&#34;Hex    : 0x%s\n&#34;, a);
    printf (&#34;Dec    : %s\n&#34;, b);

}&lt;/pre&gt;
&lt;h6 class=&#34;zemanta-related-title&#34; style=&#34;font-size: 1em;&#34;&gt;
  Related articles
&lt;/h6&gt;
&lt;ul class=&#34;zemanta-article-ul&#34;&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://seclists.org/fulldisclosure/2012/Apr/13&#34; target=&#34;_blank&#34;&gt;Re: iis bug&lt;/a&gt; (seclists.org)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://www.daniweb.com/software-development/c/threads/420145/problem-of-file-transfer-in-socket-programming&#34; target=&#34;_blank&#34;&gt;Problem of file transfer in socket programming&lt;/a&gt; (daniweb.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://jetcracker.wordpress.com/2012/02/23/c-echo-implementation/&#34; target=&#34;_blank&#34;&gt;[Unix C] ECHO Implementation&lt;/a&gt; (jetcracker.wordpress.com)
  &lt;/li&gt;
  &lt;li class=&#34;zemanta-article-ul-li&#34;&gt;
    &lt;a href=&#34;http://sourcecode4all.wordpress.com/2012/04/03/character-stuffing-in-c/&#34; target=&#34;_blank&#34;&gt;Character Stuffing in C&lt;/a&gt; (sourcecode4all.wordpress.com)
  &lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;zemanta-pixie&#34; style=&#34;margin-top: 10px; height: 15px;&#34;&gt;
  &lt;a class=&#34;zemanta-pixie-a&#34; title=&#34;Enhanced by Zemanta&#34; href=&#34;http://www.zemanta.com/&#34;&gt;&lt;img class=&#34;zemanta-pixie-img&#34; style=&#34;border: none; float: right;&#34; src=&#34;https://i1.wp.com/img.zemanta.com/zemified_e.png?w=688&#34; alt=&#34;Enhanced by Zemanta&#34; data-recalc-dims=&#34;1&#34; /&gt;&lt;/a&gt;
&lt;/div&gt;</description>
    </item>
    
    <item>
      <title>Get yourself some conkyrc files.</title>
      <link>/2011/10/05/conkyrc-files/</link>
      <pubDate>Wed, 05 Oct 2011 15:18:56 +0000</pubDate>
      
      <guid>/2011/10/05/conkyrc-files/</guid>
      <description>&lt;p&gt;If you are looking for some nice conkyrc &lt;a class=&#34;zem_slink&#34; title=&#34;Computer file&#34; href=&#34;http://en.wikipedia.org/wiki/Computer_file&#34; rel=&#34;wikipedia&#34;&gt;files&lt;/a&gt;, then you can head over to :&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://ubuntuforums.org/showthread.php?t=281865&#34; title=&#34;conkyrc&#34;&gt;Ubuntu Forums&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In this thread you can see some very nice conkyrc files with screenshots. You can browse through the thread and get the one that you like. But if you are like me and would like to download all of them to see the features and commands in each of them then you would need to copy each of these files and paste them separately. But if you have to do everything manually then there’s not much of being on &lt;a class=&#34;zem_slink&#34; title=&#34;Linux&#34; href=&#34;http://www.kernel.org/&#34; rel=&#34;homepage&#34;&gt;Linux&lt;/a&gt; 🙂&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>All in one solution for all the scripts of vim from vim.org</title>
      <link>/2011/03/09/all-in-one-solution-for-all-the-scripts-of-vim-from-vim-org/</link>
      <pubDate>Wed, 09 Mar 2011 16:39:52 +0000</pubDate>
      
      <guid>/2011/03/09/all-in-one-solution-for-all-the-scripts-of-vim-from-vim-org/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;For quite sometime now, I was looking for some console based program which would help me get the scripts from vim.org. A simple solution would have been to do a wget for the scripts. But since there are so many scripts coming up daily and with a need to search based on script ID and name of the script, I thought better to write a script that can do all of those things. Now, what was required was that the script should be either able to download this or add to the &lt;a title=&#34;GLVS&#34; href=&#34;http://www.vim.org/scripts/script.php?script_id=2444&#34; target=&#34;_blank&#34;&gt;GLVS&lt;/a&gt; script. Also note that, I had done something similar in the past &lt;a title=&#34;vim – get the list of all the scripts available.&#34; href=&#34;http://blog.amit-agarwal.co.in/2010/05/28/vim-get-the-list-of-all-the-scripts-available/&#34; target=&#34;_blank&#34;&gt;here&lt;/a&gt;. There are some additions in the below script. You can download a copy of the script &lt;a href=&#34;http://blog.amit-agarwal.co.in/wp-content/uploads/2011/03/get_vim_scripts.txt&#34;&gt;get_vim_scripts&lt;/a&gt;. Or you can copy the script from below:&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>bash – echo command with option to display the output on the same line.</title>
      <link>/2010/09/21/bash-echo-command-with-option-to-display-the-output-on-the-same-line/</link>
      <pubDate>Tue, 21 Sep 2010 15:15:05 +0000</pubDate>
      
      <guid>/2010/09/21/bash-echo-command-with-option-to-display-the-output-on-the-same-line/</guid>
      <description>&lt;!--[ad#ad-2]--&gt;
&lt;p&gt;Here is a nice little trick to display the output in the same line :&lt;/p&gt;
&lt;div class=&#34;codecolorer-container bash 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;
        &lt;/div&gt;
      &lt;/td&gt;
&lt;pre&gt;&lt;code&gt;  &amp;lt;td&amp;gt;
    &amp;lt;div class=&amp;quot;bash codecolorer&amp;quot;&amp;gt;
      &amp;amp;nbsp;&amp;lt;span class=&amp;quot;kw3&amp;quot;&amp;gt;echo&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;re5&amp;quot;&amp;gt;-ne&amp;lt;/span&amp;gt; &amp;lt;span class=&amp;quot;st0&amp;quot;&amp;gt;&amp;quot;output\&amp;lt;span class=&amp;quot;es1&amp;quot;&amp;gt;\r&amp;lt;/span&amp;gt;&amp;quot;&amp;lt;/span&amp;gt;
    &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;The trick here is simple, first we disable the &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Newline&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Newline&amp;quot;&amp;gt;newline&lt;/a&gt; printed by &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Echo (command)&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Echo_%28command%29&amp;quot;&amp;gt;echo command&lt;/a&gt; with the &amp;amp;#8221;&lt;strong&gt;-n&lt;/strong&gt;&amp;amp;#8221; option and then we enable the interpretation of the &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Backslash&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Backslash&amp;quot;&amp;gt;backslash&lt;/a&gt; characters with the &amp;amp;#8221;&lt;strong&gt;-e&lt;/strong&gt;&amp;amp;#8221; option. As the &amp;amp;#8221;\r&amp;amp;#8221; is used as &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Carriage return&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Carriage_return&amp;quot;&amp;gt;carriage return&lt;/a&gt; which brings you to the start of the line without the newline (like in &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;Typewriter&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/Typewriter&amp;quot;&amp;gt;typewriter&lt;/a&gt;), we will use the same to get the desired effect. So, if you wanted a stopwatch for a 100 seconds on the console then this simple bash &amp;lt;a class=&amp;quot;zem_slink&amp;quot; title=&amp;quot;For loop&amp;quot; rel=&amp;quot;wikipedia&amp;quot; href=&amp;quot;http://en.wikipedia.org/wiki/For_loop&amp;quot;&amp;gt;for loop&lt;/a&gt; would do the same:&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>
