Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data
Posted On Thu May 03, 2007 By linux In Linux Shell Programming Forums And Topics Discussions Forums
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
2. enter this command
3. enter this command
4. enter this command
5. enter this command
6. enter this
7. enter this command
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.
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.echo $a
2. enter this command
read xxx
No prompt is displayed but the shell is waiting for input from you3. 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 variable5. 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.
CyTG Sat Mar 13, 2010
Spent ~5 minutes searching for a way to input values for the variables using the prompt (but not as an input argument)...and then I ran into this post...the title says it all - "creating a linux shell script with variable with user input form prompt to enter data"
So, THANKS A LOT!
So, THANKS A LOT!
Januka Fri Jan 29, 2010
I was looking for a simple answer for a rather new question (to me) and this page hit the nail on the head. THANKS!
unix Fri Jan 16, 2009
you are amazing in teaching us about creating a shell script. mine works i have red hat fedora linux so its simlar to unix and i followed your steps and they helped me with creating a bash script in a linux bash script. i will like to show you a script in unix ksh on line bash sed programm to run this tutorial and many other tutorials to learn the faq of pbash and csh and csh and ksh sed bash tutorial with ftp. i also want to know how to show the date using a if for loop because if there is a loop for loop in bash tutorial will export and then exit the tutorial with the loops of for now if if the if perl is installed then you can use bash and awk or grep to find a file and then execute expect if for loop find ftp tutorial programm programm run nline variable software learn example echo variables tutorial history date cron read line directory strtrainfile ssh redhat line functions user tutorials function array line rename operatsystem redhat certification perl server redhat red hat books trainsoftware book server telnet rename multiple files howto support administration ssh help dedicated server download mandrake certification tutorial pdf os damn small review if you any any reviews you can give me that would also be helpful i just want to be able to show you how you can do this so as soon as i learn all that i will post here and show you how you can do this because this is a great start to learning unix. but i must say its very hard to learn and memorize all the commands i think thats what makes learing linux so much harder
che Mon May 26, 2008
very good.. thanks a lot for the post
kila Mon May 14, 2007
can you pls list the command for me to prompt the user to enter name
gaurav Thu Nov 22, 2012
sir, i want to take input from user using a gui interface like input box and want to store it in variables, but i am unable to do it. can you tell me how can i do it..
Thanks
Regards
Gaurav Garg
tipswell dot com
Thanks
Regards
Gaurav Garg
tipswell dot com
Related Content
Information
Forums »
Linux Shell Programming Forums And Topics Discussions »
Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data
Linux Shell Programming Forums And Topics Discussions »
Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data
Title: Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data
Description: Creating A Linux Shell Script With Variable With User Input Form Prompt To Enter Data
Tags: creating ,a ,linux ,shell ,script ,with ,variable ,with ,user ,input ,form ,prompt ,to ,enter ,data ,
Info: This Post Has Been Viewed 0 Times Since
Date: Thu May 03, 2007
Author linux Received 6 Replies #1364
Date: Thu May 03, 2007
Author linux Received 6 Replies #1364
Share
URL: 

Embed: 

To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it
BBCODE:: 

BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
wallpaperama | Wallpapers | Forums | Terms Of Service
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5