kartlad
kartlad

Reputation: 243

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!

Upvotes: 1

Views: 56

Answers (2)

washingon
washingon

Reputation: 1141

The program arguments are in $1, $2, and so on.

Upvotes: 0

tso
tso

Reputation: 4934

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

Upvotes: 1

Related Questions