Solved

Comparing Variables in strings

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now