Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting variable length in Bourne Shell

Posted on 1998-03-13
2
Medium Priority
?
388 Views
Last Modified: 2013-12-26
I am writing a bourne shell application which accepts input from a user.  The value that is entered MUST be a three digit number.  What is the best (easiest) way to validate this variable ?
0
Comment
Question by:resedlar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 200 total points
ID: 1296132
Assuming your variable is $USERINPUT:

$LENGTH=`echo $USERINPUT | wc -m`


0
 

Expert Comment

by:sethu
ID: 1296133
Thank You ! Thank You ! Thank You !

Both jhance's and sethu's solutions work the only difference is that using the "wc -m" gives the length of the string + 1, but for the application I am writing that only means that the returned value should equal 4 instead of 3.


0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

705 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