epcim
2/9/2016 - 9:27 AM

bash parse input into positional attributes

bash parse input into positional attributes

set $text
#After that, individual words in $text will be in $1, $2, $3, etc. For robustness, one usually does

set -- junk $text
shift
#to handle the case where $text is empty or start with a dash. For example:


text="This is          a              test"
set -- junk $text
shift
for word; do
  echo "[$word]"
done