0

I am writing a shell script command which counts the characters typed. I am using wc. My script is echo $1 | wc -c. The problem is that it is counting a +1 character. For example, if i type 'hello' it displays (6) characters typed but it should display (5). Any ideas on how I can solve this problem?

cmd
  • 11,622
  • 7
  • 51
  • 61

1 Answers1

0

Depending on the shell you're using, you could do this:

$ var='hello'
$ echo ${#var}
5

This way you don't need to call an external program.

jwk
  • 1