Initialise a String
To initialise a string in Bash, use the assignment operator and provide variable as left operand and the value itself as right operand.
Syntax
The syntax to initialise a string in Bash is
variablename=value
ADVERTISEMENT
Example
In the following script, we initialise a variable with string value “hello world” and print it to console output.
Example.sh
str="hello world" echo $str
Output
hello world
Conclusion
In this Bash Tutorial, we have learnt how to initialise a string in Bash shell.