'character limit with " read" in shell script

I am working on a shell script to take developer initial which later on will be used in the output file. so I am using read -p "enter developer Initial:: " VAR Is there a way to limit the number of character input? If VAR is < 3 or >3 it should not take it and ask it again or stop taking at exact 3 characters? e.g. NNP. Also, How can I store this VAR input to a local file at the same time and once store use this file to read it when next time I am running this script so I do not have to input initials every time I run this script?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source