awk¶
read awk command from file¶
print selected fields¶
$0is for the entire lineNFnumber of fields
reverse words in line¶
sum of a field¶
ENDwill only execute once/^total/{next}exclude first line starts withtotal
group another field by one field¶
delimiter is space
awk
associate arrayis a dictionaryNF > 8only when the number of fields > 8
select table rows based on columns¶
Regex patterns should be put in // and not quoted. Include the header as well.
#MaxDataDiskCount MemoryInMb Name NumberOfCores OsDiskSizeInMb ResourceDiskSizeInMb
az vm list-sizes --location "australiaeast" -o table \
| awk '(($3 == "Name" || $3 ~ /^Standard_DS/) \
&& ($2 == "MemoryInMb" || $2 >= 32000) \
&& ($4 == "NumberOfCores" || ($4 >= 4 && $4 <= 20)))'
Convert string to number input: path_to_my_file.txt
NAME CPU(cores) MEMORY(bytes)
dev-dashboard-6570x79 2m 533Mi
dev-task-734449-2h882 1096m 4442Mi
dev-task-734449-d5k9m 1m 4531Mi
dev-task-734449-d996d 37m 6232Mi
dev-task and cpu > 1000m. $2 + 0 will convert string to number.