EN
Bash - read variable from command line
3 points
In this article, we would like to show you how to read variable from command line in Bash.
Quick solution:
xxxxxxxxxx
1
2
3
read variable
4
5
echo "Entered value is $variable"
In this example, we use read
command with -p
option to print the message before reading the value from command line. Then we set value as variable
and print it using echo
command.
xxxxxxxxxx
1
2
3
read -p "Enter value: " variable
4
5
echo "Entered value is $variable"