How to edit particular cell of csv file using shell script

I have one csv file and in that I want update particular cell. I know the row and coloumn number for that respective.

Please help me...

To get a precise answer post a short example and use CODE tags please.

.csv is like something

data1,1,2,3,4
data2,1,2,3,3

now in 2nd row I want to change 2 to 5....

Required one is

data1,1,2,3,4
data2,1,5,3,3

Thanks
zaxxon for updating me...

r is the row (the line number in the file)
c is the column number
v is the replacement value

This will replace column 3, row 2 with 5, no matter what the value of the cell:

nawk -v r=2 -v c=3 -v val=5 -F, 'BEGIN{OFS=","}; NR != r; NR == r {$c = val; print}' mydata

p is the previous value

This will replace only if the current value of the cell is equal to p

nawk -v r=2 -v c=3 -v p=2 -v val=5 -F, 'BEGIN{OFS=","}; NR != r; NR == r {if($r == p){$r = val}; print}' mydata

I have use ur suggesting but I m getting an error regarding file... File is in current directory..

awk -v r=15 19 -v c=7 -v val=96 -F, 'BEGIN{OFS=","}; NR != r; NR == r {$c = val; print}' OFED_coverage.csv
awk: cmd. line:2: fatal: cannot open file `-v' for reading (No such file or directory)

Deepak,

  1. Please put CODE tags around Unix stuff (see the reply by zaxxon, a Mod). It makes it easier to read.

  2. Please check your command (see below, my emphasis)

awk -v r=15 19 -v c=7 -v val=96 -F,
open $fh,"<","a.txt";
my ($row,$col,$val)=(4,1,'haha');
while(<$fh>){
	if($.==$row){
		my @arr=split;
		$arr[$col-1]=$val;
		print join " ",@arr;
		print "\n";
	}
	else{
		print;
	}
}