how to use grep, or awk, or sed.. to print the values based on pattern?
<p>The input file is below,</p>

<blockquote>
  <p>192.168.2.4,21/tcp//ftp///,23/tcp//ssh/// </p>
  
  <p>192.168.2.5,53/tcp//dns///,80/tcp//http/// </p>
</blockquote>

<p>when I put 'ftp' as argument, the output should be</p>

<blockquote>
  <p>192.168.2.4,21/tcp//ftp///</p>
</blockquote>

<p>put 'ftp ssh', the output should be</p>

<blockquote>
  <p>192.168.2.4,21/tcp//ftp///,23/tcp//ssh///  </p>
</blockquote>

<p>I tried on awk grep egrep so far, but the result doesn't fit.</p>

<p>grep: I tried grep  -o -e"pattern1" -e"pattern2"
This method will only print out the matched value with a bother newline.</p>

<p>awk: I tried to split the line to columns by ",", and for column2 to end of line, only print the matched value. (just an idea, cannot find any example online)  </p>

<p>Thanks!</p>