I want to replace all occurrences of a number with a random number in each line of a file using "sed". For example, if my file has the number 892 in each line, I would like to replace that with a unique random number between 800 and 900.
Input file:-
temp11;djaxfile11;892
temp12;djaxfile11;892
temp13;djaxfile11;892
temp14;djaxfile11;892
temp15;djaxfile11;892
Expected output file :-
temp11;djaxfile11;805
temp12;djaxfile11;846
temp13;djaxfile11;833
temp14;djaxfile11;881
temp15;djaxfile11;810
I am trying the below:-
sed -i -- "s/;892/;`echo $RANDOM % 100 + 800 | bc`/g" file.txt
but it is replacing all the occurrences of 892 with a single random number between 800 and 900.
Output file :-
temp11;djaxfile11;821
temp12;djaxfile11;821
temp13;djaxfile11;821
temp14;djaxfile11;821
temp15;djaxfile11;821
Could you please help in correcting my code ? Thanks in advance.