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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Character Count 1

Status
Not open for further replies.

Arrumac

Technical User
Jan 30, 2002
8
0
0
GB
What is the simplest way to count the number of characters in a variable string and test this = 7 for example

Cheers

Adam
 
#!/usr/bin/ksh

MESSAGE="hello"
MESSAGE_LENGTH=${#MESSAGE}

echo "$MESSAGE has $MESSAGE_LENGTH letters."
if [ $MESSAGE_LENGTH -eq 5 ]
then
echo "$MESSAGE has $MESSAGE_LENGTH letters."
fi Robert G. Jordan
Unix Sys Admin
Sleepy Hollow, Illinois U.S.A.
sh.gif


FREE Unix Scripts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top