Solved

KSH Script - Compare variable with expression

Posted on 2006-10-19
2
940 Views
Last Modified: 2013-12-26
I do not know if this is the best way.  This is the beginning of building a bigger script. I am trying to see if a variable is a digit (3 digits between 0-9) in a ksh script. Do I need to verify the variable before I get into the IF statement?

for list in `grep -l '\*\*\*\*\*' ??????`
do
    varLine=`head -l -n 1 $list`
    varDocType=`echo "$varLine" | cut -c23-25`
    if [ varDocType -eq +([0-9]) ]
    then
        echo "Filename=$list Document Type=$varDocType"
    else
        echo "Not Correct Type"
    fi
done
0
Comment
Question by:TomTinsley
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 250 total points
Comment Utility
case $varDocType in
[0-9][0-9][0-9])
   echo "Filename=$list Document Type=$varDocType";;
*)
        echo "Not Correct Type";;
esac
0
 
LVL 3

Author Comment

by:TomTinsley
Comment Utility
Thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

762 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

12 Experts available now in Live!

Get 1:1 Help Now