Bash script to return correct value on Updates statement : <p>I've written a small script to check for Updates.
I'm looking for it to output 1 of 3 answers:</p>

<ol>
<li>If there are no updates, return "Your system is up to date"</li>
<li>If there is only one update avaiable, return "There is 1 Update available"</li>
<li>If there is more than one update, return "There are $NUMOFUPDATES Updates available"</li>
</ol>

<p>Here is what I have so far:</p>

<pre><code>#!/bin/bash
# Check for Updates

# Variables

NUMOFUPDATES=$(LANG=C apt-get upgrade -s |grep -P '^\d+ upgraded'|cut -d" " -f1)
UPDATEY1="There is 1 Update available"
UPDATEY2="There are $NUMOFUPDATES Updates available"
UPDATEN="Your system is up to date"

if [ $NUMOFUPDATES -gt 0 ]; then
    echo "\${color3}"$UPDATEY2  # Number of updates available

elif [ $NUMOFUPDATES -eq 1 ]; then
    echo "\${color3}"$UPDATEY1  # Number of updates available

else
    echo "\${color2}"$UPDATEN   # System is up to date
fi

exit 0
</code></pre>

<p>What it is not doing, is showing if there is only 1 update, it's not returning "There is 1 Update available" it's returning "There are $NUMOFUPDATES Updates available"</p>

<p>I feel like I'm close to the solution. Can someone please help me find a solution to this?</p>

<p>Thank you.</p>
