I am trying to write a script that does the following:

1. Given a string that look like this "There are 5 apples and 3 oranges"
2. Extract the two integers (5, 3)
3. Compare them

I got the extract part done.

```
NUM=echo $String | grep -o "[0-9]\+"

```

But NUM will be something like this:

```
5
3
\n

```

I tried `${NUM[0]}` and `${NUM[@]}` just to get the first value but it doesn't work.

Any suggestions?