---
title: "一个区分号码运营商的脚本"
author: "redalx"
date: "2010-04-02T17:46:14Z"
tags: ["Bash", "F#", "脚本"]
categories: ["行业应用"]
slug: "untitled"
draft: false
lastmod: "2010-04-02T17:46:14Z"
id: 631067
url: "https://redalx.iteye.com/blog/631067"
---

完全没有技术含量，不过由于号段变化的原因，记不住号段所属运营商，做一个记录：

```java
#!/bin/bash
temp_file1=`mktemp /tmp/temp.XXXXXX`
cat $1 |sed -e 's/^ *//g' -e 's/ *$//g' >$temp_file1
awk -F "[ \t|\r\n,]" '{if(length($1)!=11){print $1>>"errno.txt"}else if($1~/^(130|131|132|155|156|186)/){print $1>>"lt.txt"}else if($1~/^(0|133|153|189)/){print $1>>"cdma.txt"}else if($1~/^(134|135|136|137|138|139|150|151|152|158|159|187|188)/){print $1>>"yd.txt"}else{print $1>>"errno.txt"}}' $temp_file1
rm -rf $temp_file1
```