Solved

Comparing Variables in strings

Posted on 2002-06-05
2
258 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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

685 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