Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Comparing Variables in strings

Posted on 2002-06-05
2
Medium Priority
?
266 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 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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…
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…

886 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