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

x
?
Solved

KSH Script - Compare variable with expression

Posted on 2006-10-19
2
Medium Priority
?
962 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 85

Accepted Solution

by:
ozo earned 1000 total points
ID: 17769113
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
ID: 17769151
Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

876 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