The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
TEST command amatuer_lee_3 Shell Programming and Scripting 4 05-09-2008 08:36 AM
Test command JWilliams AIX 2 12-04-2007 02:53 AM
test command looks strange... jjinno Shell Programming and Scripting 2 11-02-2007 07:31 PM
test command is not working zam Shell Programming and Scripting 2 07-04-2006 10:42 PM
Linux test command pvar Linux 4 07-15-2004 07:23 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-22-2007
marwan marwan is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 20
the TEST command

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?
Thanks in advance
  #2 (permalink)  
Old 04-23-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Add back slash
Code:
test 20070327.gz \> 20070320.gz
  #3 (permalink)  
Old 04-23-2007
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
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}
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0