subtitute value of certain raw and column with sed

Dear All,

For example the content of data.txt file is:

1 1 23
2 1 42
3 2 52
4 2 62
5 1 77
6 1 88
7 2 99
8 1 100

Could I substitute 2 in second column with 1 using sed commad so that the data will be change as follow ?

1 1 23
2 1 42
3 1 52
4 1 62
5 1 77
6 1 88
7 1 99
8 1 100

is it also possible to change only one of them (e.g only second column third line) so that the data become:

1 1 23
2 1 42
3 2 52
4 1 62
5 1 77
6 1 88
7 2 99
8 1 100

thank you for you help in advance

best regards,

Much easier with awk, to substitute the second column of the whole file:

awk '{$2=2}1' file

To substitute the second column of the third line:

awk 'NR==3{$2=2}1' file

Regards