Solved

Counting charcters

Posted on 2001-06-07
2
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best way to handle awk return value 6 79
Linux : can't create transaction lock error 1 92
MarkLogic 1 117
capture vmstat info and insert it into an oracle table 31 92
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

739 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