0

Does anyone know of an easier way to limit the output of an echo command to x number of characters within a bash script?

ie. Snippet:

echo "Enter string: "
read -N10 string
echo

To avoid exiting and continuing key press:

Enter string:
kkkkkkkkkk
$ kkkkkkkkkk

Basically, I want the output to cut off after 10 characters and the variable 'string' to hold those 10 characters so that I can use that string variable later on as opposed to the above scenario.

Any easier way to do this or something similar?

Many thanks.

Data
  • 215
  • 2
  • 7

0 Answers0