Solved

Comparing Variables in strings

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AIX print queues constantly going down 11 524
what is the meaning of filesystem loop detected? 7 1,048
Linux performance issues with 100% swap usage, etc 15 93
ftpcommand 2 64
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

770 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