Question: I have a log line that I am pulling from bash like:

```
There are 5 apples and 7 oranges

```

And I want to get the 5 and 7 into bash variables and am having problems doing so.

awk '{ print $3, $6 }' won't work due to the fact that their position might change, if there are bananas. Bonus points if the digits can be associated with their fruits.

Thanks in advance

Answer: 
and to get the fruits:

```
echo 'There are 5 apples and 7 oranges' | grep -o -E '[[:digit:]]+ [[:alpha:]]+'

```
Well, shell is a strange language, and you can do nice things. For example:

```
a="there are 7 apples"
for i in $a; do
  case $i in
    [0-9]*)
      value=$i
      expectname=1
    ;;
    *)
      test -n "$expectname" && name=$i
      expectname=
    ;;
  esac
done

echo $value
echo $name

```

If you have more than one occurrence, you can fill an array, or a bash map.