Skip to content

Instantly share code, notes, and snippets.

@ziggear
Created February 13, 2014 06:14
Show Gist options
  • Save ziggear/8970652 to your computer and use it in GitHub Desktop.
Save ziggear/8970652 to your computer and use it in GitHub Desktop.
城市列表处理 bash
#!/bin/bash
RAW="庆:101050901七台河:101051002鸡西:101051101鹤岗:101051201齐齐哈尔:101050201大兴安岭:101050701长春:101060101延吉:101060301四平:101060401白山:101060901白城:101060601辽源:101060701松原:101060801吉林:101060201通化:101060501沈阳:101070101鞍山:101070301抚顺:101070401本溪:101070501丹东:101070601葫芦岛:101071401营口:101070801阜新:101070901辽阳:101071001铁岭:101071101朝阳:101071201盘锦:101071301大连:101070201锦州:101070701"
echo $RAW | grep -Eo '(.+?):([0-9]+)' | awk -F ':' '
BEGIN{
printf "%-12s %-12s \n","City","Number"
printf "-------------------------\n"
}
{
printf "%-12s %-12s \n",$1,$2
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment