Associative arrays (hash, dictionary) on bash

This is how to create associative arrays (hash, dictionary) on bash: #!/bin/bash if [ “$1” == “help” ] then echo “Help”; echo “USAGE:”; echo “========”; echo “purge_landingpage_varnish.sh LIVE|STAGE”; exit 0; elif [ $1 ] then DOMAINS[‘LIVE’]=”www.ask-sheldon.com”; DOMAINS[‘STAGE’]=”stage.ask-sheldon.com; REQUEST_DOMAIN=””; if [ “$1” == “LIVE” -o “$1” == “STAGE” ] then REQUEST_DOMAIN=${DOMAINS[“$1”]}; else echo “You have to give […]

Download or upload a file over SSH

#Copy something from this system to some other system: $> scp /path/to/local/file username@hostname:/path/to/remote/file   #Copy something from some system to some other system: $> scp username1@hostname1:/path/to/file username2@hostname2:/path/to/other/file   #Copy something from another system to this system: $> scp username@hostname:/path/to/remote/file /path/to/local/file You can add a port with the -P param You can do it recursive with […]

Compress and extract files

With tar On Unix based plattforms you can use the tar command for file compression and also for later uncompression. Compression $> tar -pczf web.tar.gz web/ With -h as the first parameter the real files instead symbolic links are compressed. So you can tar symbolic link targets. To exclude files or folder, you can define –exclude=’fileOFolderPath’ directly […]