How would I chown everything found by grep
<p>I am looking to chown all files that contain the word "hi"</p>

<p>I currently have</p>

<pre><code>grep -r $1 $2
if [ $? -eq 0 ]; then
        echo "Found text"
        echo $match
        echo "start"
</code></pre>

<p>with input being something such as <code>./test.sh "hi" *</code></p>

<p>I am able to obtain all files that contain hi however when I attempt to chown I am not sure what to put with piping I know that you can pass the variables to the next argument such as;</p>

<pre><code>grep -r $1 $2 | chown user1:root *
</code></pre>

<p>but that seems to just do the entire directory and that's not what I wanted.</p>

<p>Any suggestions on what to read or look into to pass this?</p>