Hey all. I am trying to ask the user to enter two pieces of input that I will assign to variables all in one line. So for instance... I ask this:
"Please enter your name and age:"
With the following command I can do this on seperate lines. How can I do it all on one line?
Here is what I started with:
read -p "Enter your name: " name
read -p "Enter your age: " age
How can I do this on one line?
Using BASH
Just figured out part of what I wanna do by doing this:
read -p "Enter your name and age: " name age
Actually just thought of a part two to this. If this was a file named "bio" how could I set this up so that when I run bio at the command prompt I could type bio "name" "age" when running the file so it will run with these variables already assigned. Basicall I want to assign variables when file executes. I know Im asking alot here!
---------- Post updated at 11:52 AM ---------- Previous update was at 11:50 AM ----------
Why do you want my post removed out of curiosity?
No, I wanted my post removed, not yours. You could do it by adding to your script variables $1 and $2, where in
bio.sh firstarg secondarg
firstarg becomes $1 and secondarg becomes $2, understand?
---------- Post updated at 12:20 PM ---------- Previous update was at 12:17 PM ----------
To clarify, whatever parameters you run the script with are called arguments, inside of your script the first argument is referred to by $1, the second as $2 and so on.