Filter a value when using regex and grep : <p>I am reading memory usage for an android app named <code>mobile_cep</code> as follows</p>

<p><code>adb shell dumpsys meminfo | grep mobile_cep</code></p>

<p>But this command this output as </p>

<pre><code>amar@admin:~/Desktop/bash-andy$ adb shell dumpsys meminfo | grep mobile_cep
234,467K: org.carleton.iot.mobile_cep (pid 27060 / activities)
234,467K: org.carleton.iot.mobile_cep (pid 27060 / activities)
</code></pre>

<p>meaning that output is displayed twice. My goal is to find <code>234,467K</code> value multiple times so as to find the average value of memory usage. </p>

<p>The following script is used</p>

<pre><code>#!/bin/bash
counter=1
while [ $counter -le 10 ]
    do
        ((counter++))
        val1=$(adb shell dumpsys meminfo | grep mobile_cep | sed 's/:.*//')
        echo $val1
    done
echo  done
</code></pre>

<p>It gives the result as </p>

<pre><code>234,675K 234,675K
234,678K 234,678K
234,679K 234,679K
234,678K 234,678K
234,679K 234,679K
234,682K 234,682K
</code></pre>

<p>But I just want first value.</p>

<hr>

<p>How to achieve this ?</p>
