title: need help on shell script for expected output
body: <p>I have an input file called <code>input.txt</code> like this:  </p>
  
  <pre><code>powerOf|creating new file|failure
  creatEd|new file creating|failure
  powerAp|powerof server|failureof file
  </code></pre>
  
  <p>I extract the text up to just before the fist capital letter in the first field and store those snippets in <code>output.txt</code>:</p>
  
  <pre><code>power
  creat
  </code></pre>
  
  <p>I used the <code>sed</code> command to separate out the values and it's working fine.</p>
  
  <p>From the output file (<code>output.txt</code>), I need to <code>grep</code> from the first field, and output should be like below:</p>
  
  <pre><code>Power
  power:powerOf|creating new file|failure,powerAp|powerof server|failureof file
  creat
  creat:creatEd|new file creating|failure
  </code></pre>
  
  <p>I have tried a few ways but I'm not getting the expected output.</p>
  
  <p>I tried the following but I'm getting duplicate entries: </p>
  
  <pre><code>cat input.txt | cut -d '|' f1 &gt;&gt; input1.txt
  cat input1.txt | s/\([a-z]\)\([A-Z]\)/\1 \2/g &gt;&gt; output.txt
  while read -r line;do
    echo $ line
    cat input.txt |cut -d ‘|’ f1|grep $line &gt;&gt; output1. txt
  done&lt; "output.txt"
  </code></pre>
  
  <p>I have 20000 lines in the input file. I don’t know why I am getting duplicates the output. What am I doing wrong?</p>