The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Question about Setting Flags chris1234 UNIX for Dummies Questions & Answers 2 04-11-2008 09:43 AM
Processes Communication Only with flags! vaggelakis UNIX for Advanced & Expert Users 1 01-05-2008 10:23 AM
Making flags for my script rcunn87 Shell Programming and Scripting 6 06-29-2006 07:23 AM
question concerning Grep flags jalge2 AIX 2 06-22-2005 06:18 AM
What does bad elf flags mean? penguin-friend UNIX for Advanced & Expert Users 1 01-16-2002 07:27 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-07-2001
Registered User
 

Join Date: May 2001
Location: Allentown, PA
Posts: 54
Hi folks.
I'm just starting to teach myself shell scripting and am having some trouble with an if statement. I am working with a directory where only one file will reside at a time and need to evaluate if this file is compressed to determine subsequent steps. I'm using echo for testing purposes. The syntax is:

if [ * -f != "*.Z"]
then
echo "not zipped"
else
echo "zipped"
fi

my problem is with the -f flag. I do not want the script to use . or .. , only an ordinary file. When I use -f, I get the correct echo for the .Z file currently in this directory, but I get the error "-f: unknown test operator". If I remove the -f, the echo is incorrect. Whatever can I do?
Thanks,
kristy

Forum Sponsor
  #2  
Old 05-07-2001
Registered User
 

Join Date: May 2001
Location: Allentown, PA
Posts: 54
ok, I've investigated further and it doesn't look like I'm on the right track with this.
  #3  
Old 05-07-2001
Neo's Avatar
Neo Neo is offline
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 4,493
-f is a shell operator, as I recall, to test if a file exists. The way you are using the -f operator is not how -f was designed to be used, it seems.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0