text: Q:
  
  How to find the last occurrence of a string in column 1 and replace the corresponding value in column 3?
  
  I have three columns in a file as such:
  apple1        10109283      20012983
  apple1        10983102      10293809
  apple1        10293893      2349823049
  apple10       109283019     109238901
  apple10       192879234     234082034
  apple10       234908443     3450983490
  
  I would like to find the last occurrence of the string in column 1 (in this case line 3 or 6) and replace the corresponding number in column 3 with a different number. Example (replace line 3 column 3 with 444444444"
  apple1        10109283      20012983
  apple1        10983102      10293809
  apple1        10293893      444444444
  apple10       109283019     109238901
  apple10       192879234     234082034
  apple10       234908443     3450983490
  
  So far I tried using sed but it didn't work:
  sed '$s/apple1*$/444444444/'
  
  A:
  
  Pure sed solution without piping and tac
  For a case like that the line-by-line approach of sed does not help. Better process the whole buffer at once, as the -z option of GNU sed does (you seem to be using linux and GNU sed, for a portable replacement see this Q&A).
  Now you can take advantage of the greedy nature of .*: The pattern .*apple1 will match everything including the last occurrence of apple1, because all other occurences are eaten by .*.
  Then just add the next fields (\s+ for the column separator, [0-9]+ for the second column and another \s+, all GNU extended regular expressions) and surround it with () so you can reuse it in the replacement as \1. Then add the third column outside the () to get it replaced and it comes out as
  sed -zE 's/(.*\napple1\s+[0-9]+\s+)[0-9]+/\14444444/'
  
  That's it.
  Note for non-GNU sed users: A portable solution would be less handy:
  sed -E 'H;1h;$!d;x;s/(.*\napple1[[:space:]]+[0-9]+[[:space:]]+)[0-9]+/\14444444/'
  
  