気になったこと、勉強したこと、その他雑記など色々メモしていきます。。Sometimes these posts will be written in English.,

What a awesome awk!!

awk!! You're so fantastic!!

I'd love to use "awk" which is a linux command easy to format some kind of text to whatever you want.

For instance as below, you're able to get the most recent loadaverage.

$ uptime
 00:08:33 up 134 days,  7:25,  2 users,  load average: 0.03, 0.03, 0.05

$ uptime | awk -F'[ ]+' '{print $11}' |sed -e 's/,//'

Besides, you're also able to do like this.

$ echo ansible_inventory.file ansible_ssh_user=vagrant ansible_ssh_port=66666 ansible_ssh_pass=xxxxxxx

$ cat ansible_inventory.file | awk -F'[ =]' '{print "sshpass -p "$7" ssh -p "$5" "$3"@"$1}'
sshpass -p xxxxxxx ssh -p 66666 vagrant@

Using awk makes me pretty comfortable!