title: How can i print in a new column the total count for 1 column in KSH?
body: <p>Im trying to add a new column in txt file with the total count without delete other columns, already found a post here in stackoverflow but</p>
  <pre><code>cut -f1 test.txt | uniq -c | join -2 2 test.txt -
  </code></pre>
  <p>is not working for me, neither the other option in post, i mean in that post didnt answer my question, can someone help?</p>
  <p>test.txt:</p>
  <pre><code>Apple_1   1      300
  Apple_2   1      500
  Apple_2   500    1500
  Apple_2   1500   2450
  Apple_3   1      1250
  Apple_3   1250   2000
  </code></pre>
  <p>EXPECTED OUTPUT:</p>
  <pre><code>Apple_1   1      300    1
  Apple_2   1      500    3
  Apple_2   500    1500   3
  Apple_2   1500   2450   3
  Apple_3   1      1250   2
  Apple_3   1250   2000   2
  </code></pre>
  <p>Already tried with some regex and awk such:</p>
  <pre><code>awk '{count[$1]++} END {for (word in count) print word, count[word]}' file
  
  awk '{ print $0 &quot;\t&quot; ++count[$1] }'
  </code></pre>