Solved

Getting variable length in Bourne Shell

Posted on 1998-03-13
2
382 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

777 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