New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Shells script problem

Post Reply New Thread Subscribe

Thread Tools
Mbengi Bongi

Member Since: Dec 16, 2006
Posts: 25
Mbengi Bongi is on a distinguished road

Mbengi Bongi is offline
Hi Guys

I have a shellscript that is located in my $Home directory, when executed it changes to a directory called "Progs" (/$Home/Progs).

then after user input from myself it searches for another shellscript (there are a few) in that directory and if it doesn't find it it returns an error message.

What I want to achieve is how do i extend my if statement to get it to search in another directory within Progs called Extra (/$Home/Progs/Extra) if the shell script isnt found in Progs and only if the shell script isnt in Extra the script returns an error message.

My if statement looks like this:
echo -n "Enter Command: "

read FILE
if [ -f ${FILE} ]; then
echo "File not found."
I've set it up so I don't have to type ./, only scriptname

Any help would be appreciated
QUOTE Thanks

rman's Avatar
Member Since: Dec 24, 2002
Location: Los Angeles, California
Posts: 12,584
rman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud of
Mac Specs: 2 x 3.0GHz Quad-Core, 6GB OS X 10.6.8 | 15in MacBook Pro 2.2GHz OS X 10.6.8 | 64GB iPad 2 WiFi

rman is offline
if [ -f ${file} ]; then
elif [ -f ./Extra/${file} ] ; then
echo "File not found."


if [ -f ${file} -o -f ./Extra/${file} ]; then
echo "File not found."

Life isn't about waiting for the storm to pass, It's about learning to dance in the rain!
QUOTE Thanks

Post Reply New Thread Subscribe

« Installers for Cocoa Applications | Java development environment! »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Starter
Last Post
Problem With Keyboard...... mmcltd OS X - Operating System 4 02-02-2010 06:47 PM
Microsoft Messenger Problem millenium_spike OS X - Apps and Games 4 09-16-2008 01:11 AM
closed captioning problem on eyetv pumpkinwhite OS X - Apps and Games 1 09-06-2006 08:38 PM
Colour Problem On One Account stewart OS X - Operating System 0 08-25-2006 07:42 PM
G3 Hard Drive problem joe mama Apple Desktops 1 02-18-2004 01:22 PM

All times are GMT -4. The time now is 04:43 PM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?