date - if - bash

2009-04-17 Thread Erik Xavior

why isn't working? :S

if [ $(date +%H)  10 ]; then echo later then 10h; else echo before 10h;
fi;


Re: date - if - bash

2009-04-17 Thread CaT
On Fri, Apr 17, 2009 at 04:59:39PM +0200, Erik Xavior wrote:
 
 why isn't working? :S
 
 if [ $(date +%H)  10 ]; then echo later then 10h; else echo before 10h;
 fi;

Because  is a string comparison. Do

help test

in bash

or man test

-- 
  A search of his car uncovered pornography, a homemade sex aid, women's 
  stockings and a Jack Russell terrier.
- http://www.news.com.au/story/0%2C27574%2C24675808-421%2C00.html


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: date - if - bash

2009-04-17 Thread Andrew Sackville-West
On Fri, Apr 17, 2009 at 04:59:39PM +0200, Erik Xavior wrote:
 
 why isn't working? :S
 
 if [ $(date +%H)  10 ]; then echo later then 10h; else echo before 10h;
 fi;

because '' is a string operator? try '-gt'

A


signature.asc
Description: Digital signature


Re: date - if - bash

2009-04-17 Thread Erik Xavior
it gives an output, yes, but if date +%H is smaller then 10, it still says
later then 10h

if [ $(date +%H)  10 ]; then echo later then 10h; else echo before 10h;
fi;


Re: date - if - bash

2009-04-17 Thread Mike Bird
On Fri April 17 2009 07:59:39 Erik Xavior wrote:
 
 why isn't working? :S

 if [ $(date +%H)  10 ]; then echo later then 10h; else echo before
 10h; fi;


 10 created a file called 10.  You probably want -gt 10.

--Mike Bird


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org