Second option how to assign a variable is by using a raid command.
We are using grid command space and then the name of our variable using grid command is an interactive
way how to set a variable.
Classic example of read the command can be read in the age from user's input.
Then we can display Redbirds by prepending assign let's write some script to practice this option.
I will create a file called read s h
on the first line.
Don't forget to start with shebeen.
Bin bash
on the next line will ask users to put their names here.
And it means that echo command won't add new line so we can continue on the same line now by typing
good he'd name.
We are storing user input to a variable called name.
Also read age in the same way.
Read age.
Now we can print our variables to see the results.
école employs statistic
and let's bring some information about name
Eco Age.
Do not assign
age
fit and save your Edita Or
And we also need to change permission in order to Rander script.
So change mode a plus x.
Read S H
and now we can see that we have run permissions so we can run the script
so we are named John.
Age 50.
Yeah and voila we see the results works perfectly.
I will clear the screen and create new script called read to.
As I age first line is dedicated to siobhán
bit mesh on the next line we'll use it month with parameter b.
This allows us to print some message and read the user's input.
Basically it is equal and that it commands first part its message then a space and then the second part
variable name where we want to store user input on the next line.
I also add another parameters as this means that user cannot see on the screen what is typing this behavior
is usually used when we want to read someone password.
But in our case we just want to hide user age from being displayed on the screen when the script reads
it will print.
Do variables values in equal command.
Age or age
and now save the file and it and we need to go around with permissions to script.
Now we can that it
name is John.
Age is 50.
I'm typing it.
But on the screen you cannot see it.
It works great but our output is displayed on the same time as age city.
So I am going to correct it.
And I will just add new took command before printing the variables values.
So save the file and running again.
Name John H 50.
Yeah and it works perfectly.
Using grid command we can also read from files that say we want to start into a variable the content
of UTC hostname file which is in my case you want to 16.
I will create a file read from file as age
and as you will I will start with siobhán
bin bash
on the next line right.
I read hostname then let's of Dentyne which means that the variable from big file and then the file
name
on the next line will print the variable value.
Echo hostname Dallara hostname.
Now safe and create your editor.
Change permissions
and verandahs script to see the hostname file
great Valks.
Well.