Geek-Press Geeky Blog about software development


Shell Scripting

For the first time in 10 years of programming someone asked for a shell script to do a bunch of operations.

I had never done such thing but I tought it should be easy.

One thing that helped me a lot was this cheat sheet. Extremelly usefull for some basic operations.

Also I was faced with a problem: How to get a dump of a pg database that is on a remote machine?

Well, I found a nice approach thanks to website. So here is the a little sample on how to perform that:

ssh $USERNAME@$HOSTNAME "pg_dump -f /dev/stdout -t tb1 -t tb2 -t tb3 dbname" > /export/bin/dbexport.sql err=$? if [ $err -ne 0 ]; then   echo "Dump failed with error code ${err}!" fi

Was this usefull or what?