0

I am prompting the user to enter two words separated by space.
I am using read name to read name and then read last to read last word
the user inputs like name last separated by space. But read seems to be reading the
whole line. How can I read the first words and the second word separately?

1

1 Answer 1

1

In general, you can read into an array.

$ read -ra arr
sadf / asdf \ wer
tomasz@fuji:~$ printf "%s\n" "${arr[@]}"
sadf
/
asdf
\
wer

Each line in this printf output corresponds to a single array item.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .