Hi everyone!
There is a saying, "To start is the half of the completion."
I'm writing my very first blog here today and taking this decision was not easy for me. Because, you know, if you want to write something you have to spent some time on it. But I think it's a payback time for me.
I have learned lots of knowledge and precious thing from this kind of blog and I'm still learning so much too. I'm admiring open source and sharing knowledge, which is why I will try to share my humble knowledge and thoughts here.
Also, I'm a new learner of the some of things that I will share. So, if you have any corrections or ideas about the topics and writings, please let me know. You have been warned :) Goodwill and respect will be my guides. Don't afraid, my essays will be concise and short.
So, here is today's topic, "How can we get user input on bash script?"
we can get a user input and assign it a variable by
read myVariable
command. Here entry assigned to $myVariable
. Whenever I need it, I can call with that name.
But here another thing, the read
prompt doesn't show any message to the user here. When we get input, wouldn't it great, if we show a message to the user?
Here is our simple solution, we basically add -p
and our message to the read
command.
read -p "Enter your value: " myValue
Here, code snippet gets input by showingEnter your value:
and assigns it to $myValue
.
Thank you for reading.