Color output from ls – based on file type

2010-02-04 1 min read Bash Linux

Threre are certain default variables which control the color of the output from the ls command, so we will talk about them today.

The first one is to get the color output from the ”ls” command. We will look at the various ways to do this:

First is to use this with default colors:

ls –color=auto

Now this will use the default colors which might not go with your liking 🙂 So if you want to change the colors you can use the variable called LS_COLORS.

Continue reading

Setting the title of PuTTY window.

2010-02-04 1 min read GNOME Linux

Setting the title for PuTTY window is quite a simple trick. The trick is to set the PS1 with a escape sequence. When the PS1 is set with the escape sequence the variable will set the title window also. And not only can this trick be used in PuTTY but even on gnome-terminal to set the title dynamically. You can use this in the .bashrc or .bash_profile file to do it whenever you are starting the terminal.

Continue reading

Gentoo, Knoppix and Linux Console Screenshots

2010-02-03 2 min read Linux

Finally I decided to try a few distro’s that I downloaded with Beldi.

  1. Gentoo: Quite Small distribution. Did not configure my DHCP address and also did not start a X window also so did not try too much.

<a href="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/02/gentoo.jpg"><img class="size-medium wp-image-204" title="gentoo" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/gentoo-300x224.jpg" alt="gentoo" width="300" height="224" />

<a href="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/02/gentoo2.jpg"><img class="size-medium wp-image-205" title="gentoo2" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/gentoo2-300x224.jpg" alt="gentoo2" width="300" height="224" />

  1. Knoppix: Well known for its recovery functions, the Live CD does discover all the hardware and boots pretty nicely to the X windows directly with the ethernet configured.
    I specially liked the fact that the boot up to X window theme looked quite similar and the background did not change which is quite soothing. And no doubt the desktop background included by default is quite good.

<a href="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/knoppix.jpg"><img class="size-medium wp-image-207" title="knoppix" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/knoppix.jpg" alt="knoppix" width="192" height="144" />

Continue reading

Installing Sofware on Linux, easier and finding alternates.

2010-02-03 1 min read Linux

There are already some great blogs on this, why write another one. Let me just point you to the best one <a href="http://http://blogs.computerworld.com/installing_linux_software_101_for_windows_users" target="_blank">here.

Here are sites that will help you find the alternative to your favourite Windows programs:

  1. <a href="http://www.osalt.com/" target="_blank">http://www.osalt.com/

  2. <a href="http://wiki.linuxquestions.org/wiki/Linux_software_equivalent_to_Windows_software" target="_blank">http://wiki.linuxquestions.org/wiki/Linux_software_equivalent_to_Windows_software

  3. <a href="http://www.linuxalt.com/" target="_blank">http://www.linuxalt.com/

Last access time for file

2010-02-03 1 min read C Programs Linux

The C program will print the last access time for the file.

This is quite helpfull program when you want to find old files. Modifying the source to take the filename as argument and take multiple arguments is left as an exercise.

#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <time.h>
#include <stdlib.h>
int main(void)
{
    char datestring[80];
    struct  stat a;
    //int fd = open("ak",O_RDONLY);
    if (stat ("iptc.c", &a) == -1) {
        perror("stat");
        printf (" Error");
        return;
    }
    printf (" Last Access Time is %s", ctime(&a.st_atime));
    printf (" Last Access Time is %s", a.st_atime);
}

Continue reading

Built-in lists in vim

2010-02-03 1 min read Learning Linux Vim Tips

<a class="zem_slink freebase/en/vimscript" title="Vimscript" rel="wikipedia" href="http://en.wikipedia.org/wiki/Vimscript">Vimscript provides excellent support for operating on collections of <a class="zem_slink freebase/en/data" title="Data" rel="wikipedia" href="http://en.wikipedia.org/wiki/Data">data, a cornerstone of programming. In this third article in the series, learn how to use Vimscript&#8217;s built-in lists to ease everyday operations such as reformatting lists, filtering sequences of filenames, and sorting sets of line numbers. You&#8217;ll also walk through examples that demonstrate the power of lists to extend and enhance two common uses of <a class="zem_slink freebase/en/vim" title="Vim (text editor)" rel="homepage" href="http://www.vim.org/">Vim: creating a <a class="zem_slink freebase/en/user_defined_function" title="User-defined function" rel="wikipedia" href="http://en.wikipedia.org/wiki/User-defined_function">user-defined function to align assignment operators, and improving the built-in text completions mechanism.

Continue reading

Understand Awk Variables with 3 Practical Examples

2010-01-28 1 min read Learning Linux

<a id="aptureLink_gQhJKQ92Kn" style="padding: 0px 6px; float: left;" href="http://www.gnu.org/software/gawk/manual/gawk.html"><img style="border: 0px none;" title="The GNU Awk User's Guide" src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/ph/400x270_WebClip" alt="" width="400px" height="270px" />

<a id="aptureLink_CLV4LbC1Dr" style="padding: 0px 6px; float: right;" href="http://gnuwin32.sourceforge.net/packages/mawk.htm"><img style="border: 0px none;" title="Mawk for Windows" src="http://blog.amit-agarwal.com/wp-content/uploads/img.zemanta.com/ph/400x270_WebClip" alt="" width="400px" height="270px" /> This article is part of the on-going Awk Tutorial and Examples series. Like any other <a class="zem_slink freebase/en/programming_language" title="Programming language" rel="wikipedia" href="http://en.wikipedia.org/wiki/Programming_language">programming languages, Awk also has user defined variables and built-in variables. In this article let us review how to define and use <a class="zem_slink freebase/en/awk" title="AWK" rel="homepage" href="http://cm.bell-labs.com/cm/cs/awkbook/index.html">awk variables. Awk variables should begin with the letter, followed by it can consist of alpha numeric characters or underscore. Keywords […]

Continue reading
Older posts Newer posts