I am accepting input from a user by using
read. I am trying to count the result as usual with
wc -c, and store it into a variable, but the result always returns 1.
Below is the
#!/bin/bash echo -n "Enter your plaintext.> " read text count=$(echo $text | wc -w) echo $count
Somehow when the variable is not store as variable and directly echo out will be the correct result.
#!/bin/bash echo -n "Enter your plaintext.> " read text echo $text | wc -w