Skip to main content
added 6 characters in body; edited tags
Source Link
AdminBee
  • 23.6k
  • 25
  • 55
  • 77

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

echo "Please specify file:"
read FILE

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

Please can someone help?

Thanks

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

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

Source Link
user473736
user473736

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