Created
March 14, 2016 12:17
-
-
Save byteshiva/b712bc650f28746647f0 to your computer and use it in GitHub Desktop.
Search and Replace all Items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk -F 'value=' 'function randint(n) { return int(1 + n * rand()) } BEGIN{server[1]="server01";server[2]="server02";zone[1]="us-east"; zone[2]="us-west"; zone[3]="us-north"; zone[4]="us-south"; srand();} {s1=randint(2); t1=randint(4); gsub("server01",server[s1], $1); gsub("us-west",zone[t1],$1); if ($2 == "2.0") print ($1 "value="rand())""; else print $2","}' cpu_data.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cpu_load_short,direction=in,host=server01,region=us-west value=2.0
cpu_load_short,direction=in,host=server01,region=us-west value=2.0
cpu_load_short,direction=in,host=server01,region=us-west value=2.0
cpu_load_short,direction=in,host=server01,region=us-west value=2.0
cpu_load_short,direction=in,host=server01,region=us-west value=2.0
cpu_load_short,direction=in,host=server01,region=us-west value=2.0
cpu_load_short,direction=in,host=server01,region=us-west value=2.0
cpu_load_short,direction=in,host=server01,region=us-west value=2.0
cpu_load_short,direction=in,host=server01,region=us-west value=2.0
cpu_load_short,direction=in,host=server01,region=us-west value=2.0