You are not logged in.
Im testing out a bit of code to put in my arch stage 2 installation script and it works but in the exact opposite way that I want it to and I cant figure out the logic behind it, can someone clue me in?
#! /bin/bash
ls -a /home/bran | grep thunderbird
if [ -d /home/bran/.thunderbird ]; then
echo "removing thunderbird directory"
sudo rm -rf /home/bran/.thunderbird
fi
ls -a /home/bran | grep thunderbird
ln -s /media/w7/Users/bran/AppData/Roaming/Thunderbird/qmu8f6lc.default /home/bran/.thunderbird
gives the output of:
.thunderbird
.thunderbird
ln: creating symbolic link `/home/bran/.thunderbird': File exists
while if I change the if statement to this: if [ ! -d /home/bran/.thunderbird ]; then
this is the output that I get:
.thunderbird
removing thunderbird directory
which is the way I want the script to work. So my question is why does the script successfully enter the if statement when I tell it to remove the directory if the directory doesnt exist even though it does actually exist?? Its confusing the hell out of me...
Last edited by brando56894 (2009-06-19 01:30:58)
Offline
It appears that in your case ".thunderbird" is a _file_ (check in "long" format of "ls").
Last edited by TheBodziO (2009-06-18 23:03:14)
It's not the best thing when they call you a "member" you know…
Offline
Use
if [ -e /home/bran/.thunderbird ]; then
Last edited by arkham (2009-06-18 23:38:24)
"I'm Winston Wolfe. I solve problems."
~ Need moar games? [arch-games] ~ [aurcheck] AUR haz updates? ~
Offline
@ thebodzio: nope its a hidden directory for thunderbird that stores all your profile info
@ arkham: I had tried that before and it didnt work, just for the hell of it I tried it again and it worked... odd. why wouldnt the -d flag work considering it is an actual directory?
Offline
Don't get me wrong but… could you check
ls -ld .thunderbird
Last edited by TheBodziO (2009-06-19 00:40:04)
It's not the best thing when they call you a "member" you know…
Offline
[bran@ra ~]$ ls -ld .thunderbird
drwxr-xr-x 2 bran bran 4096 2009-06-17 21:17 .thunderbird
edit: it works now, thanks for the help
Last edited by brando56894 (2009-06-19 01:30:44)
Offline
Thanks for the reply! I suspect that it wasn't a directory when "things wasn't working" but hey… who knows . I'm happy that it works for you now!
It's not the best thing when they call you a "member" you know…
Offline