Thursday, 24 July 2008

unary operator expected shell script

Place quotes around your variables

if [ "$state" != "" ]
echo problem

Monday, 14 July 2008

Subtract dates in Linux

This is working for Linux
main idea find the seconds since "00:00:00 1970-01-01 UTC"
then subtract them. This is GNU extension.

$ a=$(date -d "Tue Apr 29 14:02:19 PDT 2003" +%s)
$ b=$(date -d "Tue Apr 05 14:02:19 PDT 2003" +%s)
$ d=$(( $a - $b ))
$ echo $(( $d / 3600 / 24 ))

Friday, 11 July 2008

gcc-4.1.1 solaris 10 AMD Sun Fire X4100 M2

Old version off gcc was already installed so I used it.

bunzip2 gcc-4.1.1.tar.bz2
/usr/sfw/bin/gtar xvf gcc-4.1.1.tar
cd gcc-4.1.1

We need gnu make
ln -s /usr/sfw/bin/gmake /usr/sbin/make

Env variables
export PATH=/usr/ucb:/usr/sbin:/usr/bin:/usr/local/bin:/usr/ccs/bin:/usr/sfw/bin
export CC=gcc

Configure with recommended options
./configure --with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++ --enable-shared
make install

typeflag L not recognized

Error with tar
typeflag 'L' not recognized, converting to regular file

use gtar