title: Replacing a field with another value using sed or awk
body: <p>I have a text file with following lines say;</p>
  
  <pre><code>100 200 300
  50 120 200
  60 500 340
  </code></pre>
  
  <p>I am writing a script to change the value of any field based upon user input. If user gives the column no ($colno) and row number ($rowno) in bash, I am using the following code to determine the exact field to be replaced.</p>
  
  <pre><code>awk -v i=$colno -v j=$rowno 'NR ==j {print $i}' file
  </code></pre>
  
  <p>So, if the user gives $colno as 1 and $rownno as 3 I can locate the field $1 in row 3 (60).</p>
  
  <p>Now I want to permanently replace this value (60) with some other user given value ($new_val).</p>
  
  <p>How can I do this using either sed or awk? This bit of code will allow me to change any field specified by the user with the new value specified by the user. The code should not change any other field, even with the same value. </p>
  
  <p>Please help me. Thanking you in advance.</p>