Ignore CVS and svn directories in bash autocompletion.

2012-07-07 1 min read Bash Linux

CVS and SVN directories are something that really cause lot of un-necessary nuisance. So, simple solution just ignore them 🙂

export FIGNORE=CVS:~:.o:.svn
bind 'set match-hidden-files off'
Enhanced by Zemanta

Array of all possible colors in bash script

2012-05-07 1 min read Bash Learning

Sometime back, we had looked at using colors in bash script and here is a way to create a array of all the colors.

#!/bin/bash - 
#===============================================================================
#
#          FILE:  colorarray.sh
# 
#         USAGE:  ./colorarray.sh 
# 
#   DESCRIPTION:  
# 
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR: Amit Agarwal (aka), amit.agarwal@roamware.com
#       COMPANY: Roamware India Pvt Ltd
#       CREATED: 16/04/12 17:24:09 IST
# Last modified: Mon Apr 16, 2012  05:39PM
#      REVISION:  ---
#===============================================================================
count=0
for i in 40m 41m 42m 43m 44m 45m 46m 47m
do
    for l in 0 1
    do
        echo -n "l=$l "
        for k in 0 1
        do
            # echo -n "k=$k "
            for j in {30..37}
            do
                carr[$count]="\033[$k;$j;$l;$i"
                echo -ne "${carr[$count]}$count \033[00m"
                ((count++))
            done
        done
        echo
    done
    echo
done

You can add this script to any script of your choice and you have all the 256 colors available to you in the script without additional coding. Happy coding.

Continue reading

colors in bash scripts

2012-04-30 3 min read Bash Fedora Learning
Colours
Colours (Photo credit: CherrySoda!)

I have been trying to understand the color codes for bash for a pretty long time, but somehow never got time to understand this clearly. So this time around when I was writing a script to analyze some logs. I thought I will give it a go and finally understood some part of this.

So, first we will start with this script. This is taken from here.

Continue reading

Using file partially for filenames

2012-02-12 1 min read Bash Learning

There are some commands that take file name and there are some case where you need to give file name. But there are some cases where you want to modify the file before passing it to the command. What do you do in these case’s?

I had a file containing huge amount of data and for some testing I wanted to pass only the first few lines of the file and not the complete file.  And since the file only accepted filename and would not take any input from the STDIN so only option was to create a file with the required data in a temporary file. So, I sat back to figure out some way to do it and finally found I can use this:

Continue reading

better bash debugging

2011-09-16 1 min read Bash Linux

I was trying to debug some bash scripts yesterday and learnt something new 😉
There are lot of things in bash that you can use to debug and to start with you can enable xtrace mode as follows:

set -x

With this set you will see that all the commands are printed along with all other information as they are executed.
This you can do for any line or for the function or for the whole script. Once you set the option you can turn it
off with

Continue reading
Older posts Newer posts