Skip to main content
1 of 2
user avatar
user avatar

How to limit the length of a user input in a bash script?

I am trying to create a simple bash script to read user input and use this input as a variable within my script.

It currently looks like this :

echo "Please specify file:"

read FILE

What I want it to do is to check the $FILE input and reject it if it is too long, I have tried a couple of IF commands but cannot find the test to check the length of the input.

Please can someone help?

Thanks

user473736