Oliver Marshall wrote:
> I have the following which checks for the existence of a folder ($1)
> in two locations ($folder1_source and $folder2_source). First it
> checks in the $folder1_source location then in the $ folder2_source
> location. If it finds it in neither then the $folder_source variable
> remains empty and the script quits.
> if [ -d /$folder1_source/$1 ]; then
> elif [ -d /$folder2_source/$1 ]; then
> elif [ $folder_source="" ]; then
What do you want to achieve with this statement? Did you perhaps mean
elif [ $folder_source = "" ]; then
> I want to add one more check which is that if the directory specified
> by the $1 variable is found in BOTH the /$folder1_source AND
> /$folder2_source locations then I want the script to fail.
I would change the entire block like this:
test -d "/$folder1_source/$1" -a -d "/$folder2_source/$1" && exit 1
test ! -d "/$folder1_source/$1" -a ! -d "/$folder2_source/$1" && exit 2
test -d "/$folder1_source/$1" && folder_source=1
test -d "/$folder2_source/$1" && folder_source=2
> Whats the best way of writing that last elif statement?
There is no _best_ way.
ubuntu-users mailing list
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users