if the user just inputs the return key, then you will have an empty string in your T1 variable. So, your code would end up like this:
bash script Want to capture return key and assign a value
I want to prompt a user to enter a value if he press enter I want to assign a default value in a if statement.
echo -en "Enter a value : "
if [ "$T1" == "" ]; then
Consider two things:
1) To compare two strings you need to use the == operator (almost sure that it's best than just = )
2) The most important thing is that in your particular example, you dont need an else clause. If the user input something, then you dont want to change so you dont need to execute any code. If the user hasnt input a thing, then you will change and continue.
I hope this is useful