- Forums
- Linux Programming
- Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data
This Page Contains information about Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data By linux in category Linux Programming with 6 Replies. [1364], Last Updated: Sat May 18, 2024
linux
Thu May 03, 2007
6 Comments
13198 Visits
creating a variable wit user input
at the command line, we can create variables explicityly by telling the shell the name of the variable and the value of assign. to do this, just follow these steps on my tutorial for you to learn how to program in linux
1. run these commands
a=1650
echo $a
the sh family of shells also creates variables with input read from the user.
2. enter this command
read xxx
No prompt is displayed but the shell is waiting for input from you
3. enter this command
Wallpaperama
4. enter this command
echo $xxx
a new variable named xx is created with a value of Wallpaperama. in this example, the shell interprets the read command as instruction to create a new variable using the argument to read as the new rabiable's name, and then to assign the varaible the value of wahtever the user types in until the next enter. the same procedure can be used tom odify the value of an exisitng variable
5. enter this command
read xxx
6. enter this
Get Free Wallpapers at Wallpaperama
7. enter this command
echo $xxx
the shell interprest the argument to the read command as the name of a variable and interprets whatever the user types until the next ENTER as the value ot assing to the variable. if the variable exits, its value is modigfied. if the variable does not exists, the shell crates it. a varable consisting of many words is acceptable. I am familiar with php, if you are also familiar in programming with php and HTML, think of read as a web form where you ask for user input, on the form itself, you use variables to declare user input. same here with the read utility in linux.