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:
#!/bin/bash
read variable
echo "Entered value is $variable"
Practical example
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.
#!/bin/bash
read -p "Enter value: " variable
echo "Entered value is $variable"