Search Results

Search: Posts Made By: juampal
6,294
Posted By sk1418
awk '/<x>/{srand(NR);v=rand()*50+1;printf ...
awk '/<x>/{srand(NR);v=rand()*50+1;printf "<x>%.13f</x>\n",v};!/<x>/'
6,294
Posted By sk1418
you can change the random seed to get different...
you can change the random seed to get different random number for your 'y'.
eg
awk '/y/{srand(NR*2);v=rand()*77+1;$0="<y>"v"</y>"};1' myfile.xml > filemod.xml
I think it would be ok. (I didn't...
6,294
Posted By sk1418
For your Q1: write the output to a new file is as...
For your Q1: write the output to a new file is as easy as:
awk ... inputFile > yourNewFileQ2: with precision control:
awk '/x/{srand(NR);v=rand()*50+1;printf "<x>%.13f</x>\n",v};!/x/'

you can...
6,294
Posted By sk1418
note that everytime your run this script, you get...
note that everytime your run this script, you get the same x value in same line. but in the file, every x-value should be unique. If you want to get different x-value in each run, change the srand...
Showing results 1 to 4 of 4

 
All times are GMT -4. The time now is 02:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy