Wednesday, December 28, 2011

My favorite bach command prompt PS1

cd ~
nano .profile
add following line at the end
PS1="[\u@\h \W]$ "
export PS1

logout/login

easy to read link for more.

Friday, December 23, 2011

GoldenDict is not starting due to "Another GoldenDict copy started already."

smth happen...
Golden dict could not be started. Launch from menu will not open anything.
Launch from terminal:
rivanov@rivanov-desktop:~$ goldendict
Another GoldenDict copy started already.

There is no goldendict process.

Solution:
rm -f ~/.goldendict/pid

Sunday, December 4, 2011

Bash/Shell if conditions are lazy for '&&'(AND) expressions


This script is showing that &&(AND) conditions are optimized in Bash/Shell to not calculate rest of condition if first part is already FALSE.

#!/bin/bash

IS_HOLIDAY='N'
RUN_DAYOFF='N'
#if  [ "x$IS_HOLIDAY" = "xY" ]  && [ "x$RUN_DAYOFF" != "xY" ]; then
if  [ "x$IS_HOLIDAY" = "xY" ]  && [ echo 'sdfs' ]; then
    echo "Skipping unit , today is dayoff"
else
      echo "DO unit , today is dayoff"
fi
echo "finished."