Using bash, separate servers into separate file depending on even or odd numbers -
the output comes command run our netscaler. outputs following ... 1 thing note middle 2 numbers change even/odd criteria on last digit. never have more 2 digits, we'll never hit 10.
wc-01-web1 wc-01-web4 wc-01-web3 wc-01-web5 wc-01-web8
i need populate file called "even" , "odds." if we're dealing numbers can figure out, having number within string throwing me off.
example code i'm missing part need match string.
if [ $even_servers -eq 0 ] echo $line >> evenfile else echo $line >> oddfile fi
this simple awk
command:
awk '/[02468]$/{print > "evenfile"}; /[13579]$/{print > "oddfile"}' input.txt
there must better way.
Comments
Post a Comment