Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test the length of input string 1

Status
Not open for further replies.

dickiebird

Programmer
Feb 14, 2002
758
GB
Hi Experts
I need to check that users only input 4 chars in a script
eg

echo 'Please enter name (max 4 chars) \c '
read inname
if length(${inname} > 4)
echo '\nMax 4 chars please\n\n'
fi

Is there a test for length in ksh ???????
Thanks in advance
DB ;-) Dickie Bird
db@dickiebird.freeserve.co.uk
 
Indeed there is ... use the ${#....} syntax.

echo 'Please enter name (max 4 chars) \c '
read inname
if [ ${#inname} -gt 4 ]
then
echo '\nMax 4 chars please\n\n'
fi

Greg.
 
You're a star - have a star !
;-) Dickie Bird
db@dickiebird.freeserve.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top