I've my .sh script as
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: sync.sh DIRECTORY_LOCATION"
exit 1
fi
DIRECTORY_LOCATION=$1
DEV_INSTANCE_IP=<some ip>
# Update data
scp -pR ${DEV_INSTANCE_IP}:${DIRECTORY_LOCATION}/* ${DIRECTORY_LOCATION}/
How do I run this script??
I tried sh sync.sh <path to directory>
but it echos the line Usage: sync.sh DIRECTORY_LOCATION
. Does that mean it's being run??
yes it's running, -z
flag means
-z STRING True if string is empty.
If either first argument or second is empty --> exit.
one way of getting more information is to change the shebang to #!/bin/bash -x
this will tell bash to print every line that is executed including the value of the parameters.