Solved

Getting variable length in Bourne Shell

Posted on 1998-03-13
2
383 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
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
How to create frequencies of a variable from SAS dataset? 10 133
Problem to event 3 102
Not needed 13 119
x-bar in Google Sheets 2 70
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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