I'm trying to code something that looks like that:
#!/bin/bash
echo "type your separated words"
read *all variables*
echo *all variables*
Is that possible?
You could store them into an array using read
read -p $'type your separated words:\n' -a arr
printf "%s\n" "${arr[@]}"
"%s\n" "${arr[@]}" ?%s format the array content as a string and ${arr[@]} corresponds to all of the array elements.Another solution :
$ read
str1 str2 str3
$ set -- $REPLY
$ echo "$1"
str1
$ echo "$2"
str2
$ echo "$@"
str1 str2 str3
But I prefer the 1_CR solution.