【发布时间】:2018-06-03 19:55:30
【问题描述】:
我有一个输入文件,我需要读取并应用一些条件并路由到另外两个文件。
我的输入文件,company.txt
100ABC COMPANY
2pen9999out
2cow7777out
2goa7777out
100XYZ COMPANY
2car9999out
2cow7777out
2HAT7777out
2BAL9999out
这里,以 1 开头的记录是标题,2 是详细信息
我需要创建两个文件 100ABC.txt 和 100XYZ.txt?
首先我需要检查
内联= =$(cut -f 0-1 $line) compnayName= =$( cut -f 4-6 $line)
if [ $inline -eq "1"` ] and $compnayName="ABC"
if(record start with 2 and position 4 to 8 has value like 7777)
if yes, route them in 100ABC.txt
输出:100ABC.txt
2cow7777out
2goa7777out
同样,我需要检查下一家公司 XYZ,
如果 [ $inline -eq "1"` ] 和 $compnayName="XYZ" if(记录从 2 开始,位置 4 到 8 的值类似于 7777) 如果是,请将它们路由到 100XYZ.txt
喜欢 XYZ.txt
2cow7777out
2HAT7777out
【问题讨论】: