Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am new to ksh unix shell scripting.I need my ksh script to get inputs from the user. and the number of inputs is unkown. I need to get the inputs and process again further .The sample run could be :

Enter the input values : Hello how are you

Select two values from the above : how you

Here the italized text are the inputs from the user.The inputs number given by the user is unknown .I down know how to handle the values given by user. Thanks in advance

share|improve this question

1 Answer 1

Use read to store the values:

read values?"Enter the input values: ";

Then use set to generate positional parameters:

set -- $values

Finally, print the fields matching the specified positions:

echo $1 $3

Given "Hello how are you", the output is "Hello are".

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.