Solved

Comparing Variables in strings

Posted on 2002-06-05
2
263 Views
Last Modified: 2010-04-21
I have 2 variables $newSize & $oldSize.  Each variable holds a single number corresponding to the line count of a certain file.  If $newSize is less than $oldSize, I want it to do something.  What is the syntax to put this in an If statement?

Thanx
0
Comment
Question by:RudePuppyDog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 50 total points
ID: 7058069
which shell are you using ?

  1. for sh, ksh, bash, use:

  if [ $newSize  -lt $oldSize ] ; then

      your-action-here

  fi

 
  2. For csh/tcsh using

   if ( $newSize  < $oldSize ) then
      your-action-here
   endif
     

 

0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7058714
expr $newSize '<' $oldSize
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question