#!/bin/bash
#get guojiama list
var3=country
var2=`grep $var3 db.txt > temp.txt`
for line in `cat od.txt`
do
echo $line
var1=`grep -i $line 常用国家代码.txt | awk '{print $2}'`
#get od country ,just the each line
if [ "$var1" = "" ]
then
echo "$line is not set!,var1 is$var1==================="
else
#judge the od country whether exist in the guojiama list
var3=`grep $var1 temp.txt |awk '{print $2}' `
echo "coco $var3 whether it exits,print it"
if [ $var3 = "" ]
then
echo "find one unexpected"
echo "$line is not exits,var1 is$var1++++++++++++++++++++++++++"
else
#ehco "pass"
fi
fi
done
db.txt内容如下:=====================================================================
country AD:
# 60 gHz band channels 1-4, ref: Etsi En 302 567
(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
country AE:
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 80), (3, 17)
(5250 - 5330 @ 80), (3, 24), DFS
(5490 - 5710 @ 80), (3, 24), DFS
(5735 - 5835 @ 80), (3, 30)
country AL:
(2402 - 2482 @ 20), (N/A, 20)
country AM:
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 20), (N/A, 18)
(5250 - 5330 @ 20), (N/A, 18), DFS
country AN:
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 40), (N/A, 20)
(5250 - 5330 @ 40), (N/A, 20), DFS
(5490 - 5710 @ 40), (N/A, 27), DFS
country AR:
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 80), (3, 17)
(5250 - 5330 @ 80), (3, 24), DFS
(5490 - 5710 @ 80), (3, 24), DFS
(5735 - 5835 @ 80), (3, 30)
country AT: DFS-ETSI
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 80), (N/A, 20)
(5250 - 5330 @ 80), (N/A, 20), DFS
(5490 - 5710 @ 80), (N/A, 27), DFS
# 60 gHz band channels 1-4, ref: Etsi En 302 567
(57240 - 65880 @ 2160), (N/A, 40), NO-OUTDOOR
常用国家代码.txt======================================================================
001 AF AFG 阿富汗 AFGHANISTAN
002 AL ALB 阿尔巴尼亚 ALBANIA
003 DZ DZA 阿尔及利亚 ALGERIA
005 AD AND 安道尔 ANDORRA
006 AO AGO 安哥拉 ANGOLA
010 AR ARG 阿根廷 ARGENTINA
011 AM ARM 亚美尼亚 ARMENIA
013 AU AUS 澳大利亚 AUSTRALIA
014 AT AUT 奥地利 AUSTRIA
015 AZ AZE 阿塞拜疆 AZERBAIJAN
016 BS BHR 巴哈马 BAHAMAS
017 BH BHR 巴林 BAHRAIN
018 BD BGD 孟加拉国 BANGLADESH
od.txt 文件内容======================================================================
USA
Russia
Kazahkstan
Azerbaijan
Kyrgizstan
Turkmenistan
Unzbekistan
Tadjikistan
Ukraine
Armenia
Belarus
Moldova
Georgia
Romania
Hungary
Bulgaria
Greece
Slovakia
Slovenia
Serbia
Croatia
Montenegro
Cyprus
Albania
Macedonia
Bosnia and Herzegovina
Kosovo
Czech Republic
Poland
Turkey
Egypt
Angola
Mauritius
Lebanon
Jordan
Tunisia
Mozambique
Libya
United Arab Emirates
Yemen
Iraq
Kenya
Uganda
Tanzania
Ghana
Botswana
Zimbabwe
Namibia
Ethiopia
Oman
Qatar
Kuwait
Bahrain
Saudi Arabia
Morocco
Algeria
Zambia
Pakistan
Nigeria
Germany
United Kingdom
Netherlands
Belgium
Ireland
Sweden
France
Italy
Spain
Indonesia
Vietnam
Malaysia
Thailand
Philippines
Taiwan
Singapore
Cambodia
myanmar
Laos
Hong Kong
India
Sri Lanka
Bangladesh
Nepal
1、打印文件的第一列(域) : awk '{print $1}' filename
2、打印文件的前两列(域) : awk '{print $1,$2}' filename
3、打印完第一列,然后打印第二列 : awk '{print $1 $2}' filename
4、打印文本文件的总行数 : awk 'END{print NR}' filename
5、打印文本第一行 :awk 'NR==1{print}' filename
6、打印文本第二行第一列 :sed -n "2, 1p" filename | awk 'print $1'