LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Bash scripting: "line [...]: [directory]: is a directory " ? (https://www.linuxquestions.org/questions/linux-newbie-8/bash-scripting-line-%5B-%5D-%5Bdirectory%5D-is-a-directory-593276/)

serious 10-20-2007 11:48 AM

Bash scripting: "line [...]: [directory]: is a directory " ?
 
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

serious 10-20-2007 12:08 PM

argh, so clear. simply without the $(..) and it works great. was too much influenced by the $(pwd) as I wrote that before and thought it would work this way also with the ~ *hitting head hard against wall*


All times are GMT -5. The time now is 06:58 PM.