Solved

Getting variable length in Bourne Shell

Posted on 1998-03-13
2
384 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 50 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: 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

Suggested Solutions

Title # Comments Views Activity
WinWaitActive parameters 12 31
child constructor and parent constructor, overriding and overloading 6 93
Fibonacci challenge 11 136
Problem to Office 1 44
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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