Solved

Counting charcters

Posted on 2001-06-07
2
229 Views
Last Modified: 2010-04-21
Hi all,

I am learning shell scripts. I need to do some
validations. TO do that I need to count the chars in a
given word. Could you help me in that ?

1) Accept the word from user ( I can do this :))

2) count the characters in the given word and store the
number in a variable.

3) Display the content of the variable ?

wc -c counts including end of the line or word char. How
to avoid this ?

I am using sun solaris 5.8


Thanks in advance
Gururaj
0
Comment
Question by:reach_gururaj
2 Comments
 
LVL 6

Accepted Solution

by:
bira earned 50 total points
ID: 6164491
Hi
   Save this script

   echo "accept a word"
   read word
   c=`echo $word |wc -c`
   count=`expr $c - 1`
   echo "Lenght of the word:" $count

   chmod it to 777 and run
0
 

Author Comment

by:reach_gururaj
ID: 6164920
Thanks bira.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux performance issues with 100% swap usage, etc 15 93
Expand a partition in Centos 7 Linux with Virtualmin 1 62
unix solaris snoop command 6 99
aix unix tar error 3 66
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

770 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