Friday, January 1, 2016

Happy New Year 2016 in Unix way

Wishing everyone a great 2016 ahead !

"toilet" gives you color in UNIX terminal ! Read more here

Wednesday, November 25, 2015

Display cricket score on Unix Terminal

If your job demands you to be on Unix console all the time and you happen to be one who can not avoid watching the cricket score, something you would like:
The script:
#Get cricket score on your unix console top corner, enjoy cricket while you work ..

columns=$(tput cols)

while :
  line=$(wget -q -O- $matchurl  | awk -F '=' '/og:title/ {print $3}' | awk -F '|' '{print $1}' | sed 's/"//g')
  echo -en "\033[s"    #save current screen position & attributes
  tput cup 0 $startpoint
  echo -en "\033[42m$line\033[0m"
  echo -e -n "\033[u"
  sleep 15

Friday, November 6, 2015

Bash - Get function name inside a function

$FUNCNAME has the function name in a bash script which can be used for useful purpose like the following:

WORKID=$(date +%s) ; mkdir $WORKID
LOGFILE=$WORKID/$(basename $0).log

_f_log() {
        echo "$(date):$@" >> $LOGFILE

_f_testFunc() {
        local logfile=$1
        local status=$2
        _f_log "$FUNCNAME:$logfile:$status"


_f_testFunc /tmp/a.log restart
Executing it:
$ ./
$ cat 1446805714/
Fri Nov  6 15:58:34 IST 2015:_f_testFunc:/tmp/a.log:restart

© Jadu Saikia