I'm trying to learn the basics and I have run into an issue with my script counting the characters of a user's input. Here is my script, can someone point out where I'm going wrong please?
#!/bin/bash
echo "Enter a word!"
read INPUT_STRING
len= echo $INPUT_STRING | wc -c
echo "Your character length is " $len
exit
man
command (in this caseman echo
:-n do not output trailing newline
). Frequent invocation ofman
will advance your linux skills rapidly. For more info onLC_ALL
, see this question/answer – Sebastian Sep 19 '14 at 08:34LC_ALL=C
to avoid the user's settings to interfere with your script. For instance, if you want[a-z]
to match the 26 ASCII characters from a to z, you have to setLC_ALL=C
– Sebastian Sep 19 '14 at 08:43