create text tables from delimited files.

2013-07-12 1 min read Bash Fedora

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 “tablify“. And here is how to use it:

sudo yum install perl-Text-RecordParser

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.

Continue reading

C program to get the ascii string from a string

2012-07-25 1 min read C Programs
Example diagram of the printf function in the ...
Example diagram of the printf function in the C programming language (Photo credit: Wikipedia)

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 🙂

Example output:

lp-amita[d=~/bin]> ./ascii aamit
String – aamit, Length – 5

Continue reading

Convert string to hex.

2012-04-13 1 min read C Programs

If you want to use snoop or tcpdump with advanced search 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 web application to do that or you can use a simple C program like this 🙂

/*
* =====================================================================================
*
*       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]="",b[200]="";
    printf("String - %s, Length - %d\n",argv[1],strlen(argv[1]));
    /*printf("%x\n 0x",argv[1]);*/
    while (i < strlen(argv[1])){
        /*printf("%c",argv[1][i]);*/
        sprintf(a,"%s%x",a,argv[1][i]);
        /*printf("a=%s\n",a);
        printf("b=%s\n",b);*/
        sprintf(b,"%s%d",b,argv[1][i]);
        i++;
    }
    printf ("\n");
    printf ("String : %s\n",argv[1]);
    printf ("Hex    : 0x%s\n", a);
    printf ("Dec    : %s\n", b);

}
Enhanced by Zemanta

Get yourself some conkyrc files.

2011-10-05 2 min read Fedora Linux

If you are looking for some nice conkyrc files, then you can head over to :

Ubuntu Forums

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 Linux 🙂

Continue reading

All in one solution for all the scripts of vim from vim.org

2011-03-09 9 min read Bash Fedora Learning Linux Vim Tips

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 GLVS script. Also note that, I had done something similar in the past here. There are some additions in the below script. You can download a copy of the script get_vim_scripts. Or you can copy the script from below:

Continue reading

bash – echo command with option to display the output on the same line.

2010-09-21 2 min read Bash Fedora Learning Linux

Here is a nice little trick to display the output in the same line :

  <td>
    <div class="bash codecolorer">
      &nbsp;<span class="kw3">echo</span> <span class="re5">-ne</span> <span class="st0">"output\<span class="es1">\r</span>"</span>
    </div>
  </td>
</tr>
1

The trick here is simple, first we disable the <a class="zem_slink" title="Newline" rel="wikipedia" href="http://en.wikipedia.org/wiki/Newline">newline printed by <a class="zem_slink" title="Echo (command)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Echo_%28command%29">echo command with the &#8221;-n&#8221; option and then we enable the interpretation of the <a class="zem_slink" title="Backslash" rel="wikipedia" href="http://en.wikipedia.org/wiki/Backslash">backslash characters with the &#8221;-e&#8221; option. As the &#8221;\r&#8221; is used as <a class="zem_slink" title="Carriage return" rel="wikipedia" href="http://en.wikipedia.org/wiki/Carriage_return">carriage return which brings you to the start of the line without the newline (like in <a class="zem_slink" title="Typewriter" rel="wikipedia" href="http://en.wikipedia.org/wiki/Typewriter">typewriter), 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 <a class="zem_slink" title="For loop" rel="wikipedia" href="http://en.wikipedia.org/wiki/For_loop">for loop would do the same:

Continue reading