hi everyone.
I have to write a "useful" bash script for university, but have some troubles. the script should sync two folders, but atm I can't even get the basics working.
the problem is that I wanted to define two variables within the script which can be assigned by the user or use certain default values. but this didn't really work out. atm the script throws me an error when I don't specify a variable.
the code is:
Code:
if [ "$1" == "" ]; then
DIR1=$(~)
else
DIR1=$1
fi
if [ "$2" == "" ]; then
DIR2=$(pwd)
else
DIR2=$2
fi
the error occurs in line 2 ("DIR1=$(~)") where I get the error message described in the title. what did I do wrong? or is there a more elegant solution for what I want to do? and why does it work with "DIR2=$(pwd)"?
hope someone can help me
with kindest regards
serious