[ale] bash question

Christopher Fowler cfowler at outpostsentinel.com
Mon Jul 7 13:52:16 EDT 2003


Shat is the output of the command.  What about 'sh -x'

[cfowler at cfowler tmp]$ sh -x ./test.sh 
++ date +%Y%m%d
++ cat date.txt
+ '[' 20030707 -eq 20030707 ']'
+ echo yep
yep


Here is my version:

[cfowler at cfowler tmp]$ cat test.sh 
#!/bin/sh

if [ `date +%Y%m%d` -eq `cat date.txt` ]; then
echo yep
else
echo nope
fi


On Mon, Jul 07, 2003 at 01:42:13PM -0400, 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?
> 
> Much thanks,
> CB
> 
> 
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list