anxk #
#################################################################################################
if [ $# -ne 2 ]
then
echo usage:getfields.sh system_type filename
exit
fi
cfg_dir=/work11/ruanxingke/fedx/config
filename=$2
basename $filename | awk '{print substr($0,2,2)}' | read system_type
bfile="${cfg_dir}/bill.${system_type}"
bfile1="${cfg_dir}/bill.vf"
if [ $system_type -eq "vc" ];
then
wc -l $bfile | read count file
wc -l $bfile1 | read count1 file1
cat $filename | awk -v bfile=$bfile -v bfile1=$bfile1 -v count=$count -v count1=$count1 'BEGIN {
while(getline code < bfile ) {
split(code,hash," ");
field=hash[1];
H[field]=hash[3]+1;
L[field]=hash[5];
F[field]=hash[7];
}
while(getline code1 < bfile1 ) {
split(code1,hash1," ");
field1=hash1[1];
H1[field1]=hash1[3]+1;
L1[field1]=hash1[5];
F1[field1]=hash1[7];
}
}
{
sys=substr($0,1,2)
if(sys=="vf"){
i=0;
while(i<=count1){
if (F1[i] == "*"){
printf substr($0,H1[i],L1[i])"|";
}
i++;
}
printf "\n";
}
else{
i=0;
while(i<=count){
if (F[i] == "*"){
printf substr($0,H[i],L[i])"|";
}
i++;
}
printf "\n";
}
} '
else
wc -l $bfile | read count file
cat $filename | awk -v bfile=$bfile -v count=$count 'BEGIN {
while(getline code < bfile ) {
split(code,hash," ");
field=hash[1];
H[field]=hash[3]+1;
L[field]=hash[5];
F[field]=hash[7];
}
}
{
i=0;
while(i<=count){
if (F[i] == "*"){
printf substr($0,H[i],L[i])"|";
}
i++;
}
printf "\n";
}'
fi
#分析different文件
####
shell脚本学习笔记总结_互联网_IT/计算机_专业资料。最新版的shell脚本学习笔记,对嵌入式Linux的学习很有帮助Shell 脚本编程学习笔记 2013 年 5 月 2 日 追风~...
Shell脚本测试总结_计算机软件及应用_IT/计算机_专业资料。Shell脚本测试总结1. 脚本测试的苦难因为脚本使用的自由度很大,对于程序员限制很少,功能实现的随意性给...
LINUX Shell脚本介绍总结_计算机软件及应用_IT/计算机_专业资料。LINUX Shell脚本介绍总结Shell脚本介绍 Shell脚本介绍 脚本语言是不需要事先编译,在执行时才直 接...
输入文字 Last Line Mode 主要功能:搜索或替换、存保存及结束 按q、pi、wq键 回到提示符 Shell脚本介绍创建shell脚本 指定以bash shell执行此文件 在vi输入下列...
shell脚本介绍总结shell脚本介绍总结隐藏>> Shell脚本介绍 ? 脚本语言是不需要事先编译,在执行时才直 接解释每一行程序的语言。 ? 具有接受命令行参数、用户输入...
Shell 脚本 编写总结 1. 文本操作 1) 获得文件所有字符内容 sed ‘np’ /path/filename (n 表示任意行号) cat /path/filename awk ‘{print}’ /path/...
自己总结的shell脚本学习笔记(未完待续)_互联网_IT/计算机_专业资料。关于shell脚本编程 比较全的资料 自己总结的Shell 脚本编程学习笔记 2013 年 4 月 27 日 ...
常用shell脚本命令总结_计算机软件及应用_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档常用shell脚本命令总结_计算机软件及应用_IT/计算机_专业资料。10...
常用shell脚本命令总结常用shell脚本命令总结隐藏>> 1,显 示包含文字 aaa 的下一行的内容: sed -n '/aaa/{n;p;}' filename 2,删 除当前行与下一行的...
热门文档