poor mans watch, watch for solaris
Here is a simple script that you can use as watch in Solaris as well.
watch()
{
#Poor man's watch
while (true)
do
clear
$*
sleep 2;
done
}
Here is a simple script that you can use as watch in Solaris as well.
watch()
{
#Poor man's watch
while (true)
do
clear
$*
sleep 2;
done
}
If you have a lot of CPU power and working on battery. If you do not need that much of power and would like to rather save some battery power by disabling some cpus then you can use the below script. This script disables cpus from 4 to 7. You can change the number in the for loop. You would need the sudo to be setup or remove sudo and run the script as root. The script will show you the currently active cpu’s before and after disabling the CPU’s.
Continue readingI was working on something and the data was very critical and needed backup. I wrote a bash script to back up the data every 5 hours with cron and bash script. Thought I will share that with you. Here is the script.
#!/bin/bash - #=============================================================================== # # FILE: backup.sh # # USAGE: ./backup.sh # # DESCRIPTION: Backup all the current files. # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Amit Agarwal (aka), amit.agarwal@roamware.com # COMPANY: Roamware India Pvt Ltd # CREATED: 08/19/2011 02:43:32 PM IST # REVISION: --- #=============================================================================== backupf=( a b c d) #Here you need to specify the directory you need to backup. bkupdir="/tmp/backup/$(date +%Y)/$(date +%m)/$(date +%d)" #Here you can change the basedir for the backups mkdir -p $bkupdir sudo tar cvfz $bkupdir/bkup_$(date "+%Y%m%d_%H%M").tgz $backupf[*] #Remove sudo if you do not need it. echo "Backup created in dir $dir"
And then just add it to cron as “00 */5 * * * /home//bin/backup.sh”. Change the path if it does not match what is given here.
Continue readingCVS 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'
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
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 readingHere are some pretty good links on the subject. Since there are already so many blog posts, does not make sense to add one more 🙂
http://tldp.org/HOWTO/Bash-Prompt-HOWTO/c816.html
http://www.gilesorr.com/bashprompt/prompts/
https://bbs.archlinux.org/viewtopic.php?id=84386
Bash themes – http://onlamp.com/onlamp/2006/02/02/bash_themes.html