Skip to content
Advertisement

How to take input in beginning of the program?

I am making a program which needs the user input in the beginning of the program if you don’t get my question i will give you an example:

./script.sh "some-input"

So, I want the input in the beginning of the program. I think the input will be stored in a variable. If yes, Then please tell me in which variable it is stored. I am a Linux rookie please never hesitate to correct the question. Thank you!

Advertisement

Answer

if we have:

some_program word1 word2 word3
$0 would contain "some_program"
$1 would contain "word1"
$2 would contain "word2"
$3 would contain "word3"

and $4 fourth argumet and so on

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement