Array of all possible colors in bash script

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), [email protected]
#       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.

Enhanced by Zemanta

vim – get names of the scripts and the details from the command line

For the below commands either you can set the two variables in bold and then run the scripts or change the following in the commands and run the scripts.

If you have html2text installed then you can use this:

wget -o /dev/null -O $script_id_file \’http://www.vim.org/scripts/script.php?script_id=\’$script_id |html2text

If you dont have html2text installed then you can use:

wget -o /dev/null -O $script_id_file \’http://www.vim.org/scripts/script.php?script_id=\’$script_id

\"Reblog

core dump checking script.

I was testing a program which crashing every now and then. It is very difficult in such scenarios to keep looking for the core file or keep checking for the running process. So I wrote this simple script that can check for core file in the particular path and keep running until it finds one. You can hack this script to send a mail once the core is found. This is a very simple script. And this should work on solaris too..

#!/bin/bash –

#===============================================================================

#

# FILE: check_core.sh

#

# USAGE: ./check_core.sh

#

# DESCRIPTION: Script to check for core dumps

#

# OPTIONS: —

# REQUIREMENTS: —

# BUGS: —

# NOTES: —

# AUTHOR: Amit Agarwal (AKA), [email protected]

# COMPANY: Individual

# VERSION: 1.0

# CREATED: 12/14/2009 10:19:51 AM IST

# REVISION: —

#===============================================================================

path=/home/amit/

app_name=wine

app_pid=

[ -z $app_name ] || echo $app_name , pid_app=$(ps -u `whoami` -f|grep $app_name |grep -v grep)

[ -z $app_pid ] || echo $app_pid , pid_pid=$(ps -eaf|grep $app_pid |grep -v grep)

if [ -z $pid_app ]

then

while (true)

do

cd $path

if [ -f core ]

then

echo \”Core found\”

exit

else

echo \”continue\”

sleep 5

fi

done

fi

\"Reblog