title: Replace/Update column value from text document in bash
body: <p>I got a question on how can i update an specific column value from a row in a text document in bash.
   So far I do this:
  In this case I'm trying to update the 4th column in a line from an specific account number. take the current value, sum with a new value inserted by the user and then replace that current value with the result.</p>
  
  <p>Open the script with two variable $1 holds the account I ll be looking for while $2 the file name.</p>
  
  <p>The text document has information like this:</p>
  
  <pre><code>11101   :   CAJA GENERAL            :   111     :   0
  11102   :   CAJA CHICA              :   111     :   0
  112     :   BANCOS                  :   11      :   0
  11201   :   CUENTAS CORRIENTES      :   112     :   0
  1120101 :   Banco Agrícola S.A.     :   11201   :   20
  1120102 :   Banco Hipotecario S.A.  :   11201   :   0
  11202   :   CUENTAS DE AHORRO       :   112     :   0
  1120201 :   Banco Agrícola S.A.     :   11202   :   0
  </code></pre>
  
  <p>I use this code to find the correct row and assign the current value to the var "act" and aggregate it with another new value </p>
  
  <pre><code>read -p "Inserte monto" insert
      act=$(grep -w "^$1" $2  | cut -d":" -f4)
      vare=$(($act + $insert))
  </code></pre>
  
  <p>But then I need to place this new value to the exact column/row I took the original value.</p>
  
  <p>How do i exactly do it? I'm quite exhausted from a long day of traveling and now I want to finish this and go to bed. Anyone could give me an idea or solution? I'd really appreciate any help right now.</p>
  
  <p>EDIT:
  Ok.. I went and try AWK.
  Found this to "replace" text </p>
  
  <pre><code>awk -F':' -vOFS=' '  '{ $4 = "$vare"}1'
  </code></pre>
  
  <p>So far... once I enter that line the execution of the script stops.. or I dont know what but it doesn't continue anymore, nor shows any error.
  Am I doing anything wrong?</p>
  
  <p>EDIT 2:
  Expected Input.
  After a successful update I want the selected account to have the updated value in a existing document in my directory, the solutions so far allow me to see the updates within terminal, but is the original document the one I need to see the changes. Thanks Ed Morton for the tip</p>