[ale] bash question

Pete Hardie pete.hardie at sciatl.com
Mon Jul 7 13:57:26 EDT 2003


Christopher Bergeron wrote:
> I'm trying to compare the output of a command in an if conditional using 
> bash.  The only problem is that I can't figure out how it's done, and 
> everything that I try to search for on google brings up a million 
> unrelated hits.  I looked through advanced bash scripting guide, but 
> still couldn't find the answer.  Hopefully, someone on the list can help 
> me with this one:
> 
> I have a file that contains a date in the format:
> 20030705
> 
> and I'd like to perform an if conditional like such:
> 
> if [ `date +%Y%m%d` -eq `cat datefile.txt` ]; then
> echo They match!
> else
> echo They dont match!
> fi
> 
> but that doesn't seem to work.  Can anyone give me any pointers on how I 
> can accomplish this?


IIRC, -eq is used for numeric comparison, and == is for string equality, so 
that's one possible problem.


-- 
Pete Hardie                   |   Goalie, DVSG Dart Team
     posting from, but not     |
	speaking for:             |
Scientific Atlanta, Digital Video Services Group



     - - - - - - -  Appended by Scientific-Atlanta, Inc.  - - - - - - -  
This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.

_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list