IF statement help

matteo filippetto matteo.filippetto at gmail.com
Wed Nov 11 17:27:05 UTC 2009


2009/11/11 Oliver Marshall <Oliver.Marshall at g2support.com>

>  Hi chaps,
>
>
>
> Can you help me with an if statement?
>
>
>
> 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.
>
>
>
> ****************
>
> folder_source=""
>
> if [ -d /$folder1_source/$1 ]; then
>
>                 folder_source=1
>
> elif [ -d /$folder2_source/$1 ]; then
>
>                 folder_source=2
>
> elif [ $folder_source="" ]; then
>
>     exit
>
> fi
>
> *****************
>
>
>
> 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.
>
>
>
> Whats the best way of writing that last elif statement?
>
>
>
> Olly
>
>
>
> --
>
> G2 Support
>
> Network Support : Online Backups : Server Management
>
>
>
> [image: g2supportsmall_250x58]
>
>
>
> Tel:    0845 307 3443
>
> Email:  oliver.marshall at g2support.com
>
> Web:    http://www.g2support.com
>
> Twitter: g2support <http://twitter.com/home?status=@g2support>
>
> Newsletter: http://www.g2support.com/newsletter
>
> Mail:   2nd Floor, 130a Western Rd, Brighton, Sussex, BN12LA
>
>
>
> G2 Support LLP is registered at Mill House, 103 Holmes Avenue, HOVE
>
> BN3 7LE. Our registered company number is OC316341.
>
>
>
>
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
>
Hi,

maybe you can

folder_source=""

if [ -d /$folder1_source/$1 ]; then

                folder_source=1

elif [ -d /$folder2_source/$1 ]; then

                folder_source=2

elif [ $folder_source=""  ] || [ $folder_source="1"  ] && [
$folder_source="2"  ]; then

    exit

fi
Best regards,


-- 
Matteo Filippetto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20091111/13454661/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 1969 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20091111/13454661/attachment.jpg>


More information about the ubuntu-users mailing list