title: shell script to add parentheses around regex matches after user confirmation
body: <p>I have a file tree containing thousand php files. I want to decrease the effort required to upgrade it to PHP7.2, it is now PHP5.2 - PHP5.5. So I want to start by automatically replacing some syntax.</p>
  
  <p>The first bit of syntax changed that I want to automatically replace are arrays which access a column by name. In PHP 7.2, there need to be quotation marks around the column-name. I came up with a grep command to find a lot of matches:</p>
  
  <pre><code>grep -rIC 2 "\$[A-Za-z]\{1,\}\[[A-Za-z]\{1,\}\]"
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>wws/tools/ttman001M0102.php-}
  wws/tools/ttman001M0102.php:if($operator[osno]!=""){
  wws/tools/ttman001M0102.php:    $where.=" and ".getWhereAnweisung("t10.osno",'',$operator[osno],$suche[osno]);
  wws/tools/ttman001M0102.php-}
  wws/tools/mwtxt_100L0100.php-while($r=$a-&gt;getNextRow()){
  wws/tools/mwtxt_100L0100.php:   $r[txta]=htmlentities(substr($r[txta],0,40),ENT_QUOTES,ini_get("default_charset"));
  wws/tools/mwtxt_100L0100.php-  $cust_array[$i]= $r;
  wws/tools/updates.php-  {
  wws/tools/updates.php:          //if(confirm('&lt;?php  echo $label[a]?&gt;'))
  wws/tools/updates.php-  {
  wws/tools/updates.php:          //if(confirm('&lt;?php  echo $label[a]?&gt;'))
  wws/tools/mwtxt_103M0100.php-}
  wws/tools/mwtxt_103M0100.php:if($suche[doku]!="")
  wws/tools/mwtxt_103M0100.php:   $where.=" (dsca like '%".addslashes($suche[doku])."%' or doku like '".addslashes($suche[doku])."%') and ";
  wws/tools/mwtxt_103M0100.php-if($sort_field)
  wws/tools/mwtxt_103M0100.php-while($r=$Abf-&gt;getNextRow()){
  wws/tools/mwtxt_103M0100.php:   $r[dsca]=htmlentities($r[dsca],ENT_QUOTES,ini_get("default_charset"));
  wws/tools/mwtxt_103M0100.php-  $cust_array[$i]= $r;
  wws/tools/mwtol_000M0000.php-  while($r=db_fetch_row(Array($result,"DB_GETMODE_ASSOC"))){
  wws/tools/mwtol_000M0000.php:    $mhein_040 = new query_select("select * from mhein_040 where orno='$r[liid]' and mndn = '".$_SESSION['SES_CLIENT']."'");
  wws/tools/mwtol_000M0000.php-    $kont=new CRM_Vorgang();
  wws/tools/mwtol_000M0000.php-    $kont-&gt;message=array('meid'=&gt;'mwdoc_002fristmhein_040invn','dspr_usid'=&gt;array('mhein_040usid'=&gt;$mhein_040-&gt;row[usid]),
  wws/tools/mwtol_000M0000.php:    'text'=&gt;'&lt;a href="javascript:window.open(\'../distribution/mhein_040M0000.php?glob_order_no='.$r[liid].'&amp;aktion=invn&amp;invn='.$r[bnum].'\');void(0);"&gt;'.
  wws/tools/mwtol_000M0000.php:        get_labelInLanguage('eka',$_SESSION['global_lang']).' '.$r[liid].
  wws/tools/mwtol_000M0000.php:        get_labelInLanguage('re',$_SESSION['global_lang']).' '.$r[bnum].'&lt;/a&gt;');
  wws/tools/mwtol_000M0000.php-    $kont-&gt;crm_send_saved_message();
  wws/tools/mwtol_000M0000.php-      $sql="select grou from mpart_003
  wws/tools/mwtol_000M0000.php:            where item='$feld[item]' and tabl='msser_201' and grou in ('1','2','3') and mndn = '".$_SESSION['SES_CLIENT']."'";
  wws/tools/mwtol_000M0000.php-      $gr=new query_select($sql);
  </code></pre>
  
  <p>which already outputs a suitable display of the code in question. I want to feed these results into a bash script which will ask me to replace by pressing y or n for each occurence. Is this a good approach or is there maybe a better one to speed up the process?</p>