The UNIX and Linux Forums  

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



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 04-23-2007
cfajohnson's Avatar
cfajohnson cfajohnson is offline
Registered User
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 664
Quote:
Originally Posted by marwan
Hi everyone,
I am new to UNIX and scripting, and I have some problems with the test command.
when i try to execute the command:
test 20070327.gz > 20070320.gz
i try to make a charachter string comparison between the two strings or the two files, to make sure that 20070327.gz is greater than 20070320.gz
but the command is not accepted, i think the shell interprets the > as an input output redirector, not as a (greater than)sign.
so, how can I escape this error?

Besides the solution anbu23 gave you (which I avoid, as it's not standard), there are a number of ways. For example, you could remove the suffix:

Code:
f1=20070327.gz
f2=20070320.gz
test ${f1%.gz} -gt ${f2%.gz}
Reply With Quote