Skip to content

Instantly share code, notes, and snippets.

@byteshiva
Created March 14, 2016 12:17
Show Gist options
  • Save byteshiva/b712bc650f28746647f0 to your computer and use it in GitHub Desktop.
Save byteshiva/b712bc650f28746647f0 to your computer and use it in GitHub Desktop.
Search and Replace all Items
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
@byteshiva
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment