shell 脚本
提取 基本思路 没写完 参考下
程序代码:
$ IFS=$'\n'; for line in $(grep "^#.*;$" step.txt | grep "ADVANCED_FACE") ;do echo $line; done
#28 = ADVANCED_FACE ( 'NONE', ( #325 ), #221, .F. ) ;
#77 = ADVANCED_FACE ( 'NONE', ( #326 ), #260, .T. ) ;
#108 = ADVANCED_FACE ( 'NONE', ( #188, #223 ), #266, .T. ) ;
#130 = ADVANCED_FACE ( 'NONE', ( #317 ), #213, .T. ) ;
#185 = ADVANCED_FACE ( 'NONE', ( #137 ), #184, .F. ) ;
#211 = ADVANCED_FACE ( 'NONE', ( #134 ), #242, .F. ) ;
#235 = ADVANCED_FACE ( 'NONE', ( #111 ), #40, .T. ) ;
#259 = ADVANCED_FACE ( 'NONE', ( #63 ), #65, .F. ) ;
#307 = ADVANCED_FACE ( 'NONE', ( #10 ), #227, .F. ) ;
#329 = ADVANCED_FACE ( 'NONE', ( #236 ), #257, .T. ) ;
$ IFS=$'\n'; i=0; for line in $(grep "^#.*;$" step.txt | grep "ADVANCED_FACE") ;do adv[$i]=$line; ((++i)); done
$ grep "^#.*;$" step.txt | grep "ADVANCED_FACE" | egrep -o "\( #[^\)]*\)" | sed -e 's/ //g' | egrep -o "#[^\)]*" | awk -F, '{for (i=1;i<=NF; ++i){if (i>1) printf(" ");printf("%s", $i)} printf("\n");}'
#325
#326
#188 #223
#317
#137
#134
#111
#63
#10
#236
$ i=0; for line in $(grep "^#.*;$" step.txt | grep "ADVANCED_FACE" | egrep -o "\( #[^\)]*\)" | sed -e 's/ //g' | egrep -o "#[^\)]*" | awk -F, '{for (i=1;i<=NF; ++i){if (i>1) printf(" ");printf("%s", $i)} printf("\n");}');do advline[$i]=$line; ((++i));done
$ i=0; while [ $i -le ${#advline[@]} ];do echo ${advline[$i]}; ((++i)); done
#325
#326
#188 #223
#317
#137
#134
#111
#63
#10
#236
$ i=0; while [ $i -lt ${#advline[@]} ];do echo ${advline[$i]}; egrep "^${advline[$i]} = " step.txt; ((++i)); done
#325
#325 = FACE_OUTER_BOUND ( 'NONE', #314, .T. ) ;
#326
#326 = FACE_OUTER_BOUND ( 'NONE', #87, .T. ) ;
#188 #223
#317
#317 = FACE_OUTER_BOUND ( 'NONE', #301, .T. ) ;
#137
#137 = FACE_OUTER_BOUND ( 'NONE', #272, .T. ) ;
#134
#134 = FACE_OUTER_BOUND ( 'NONE', #267, .T. ) ;
#111
#111 = FACE_OUTER_BOUND ( 'NONE', #107, .T. ) ;
#63
#63 = FACE_OUTER_BOUND ( 'NONE', #99, .T. ) ;
#10
#10 = FACE_OUTER_BOUND ( 'NONE', #18, .T. ) ;
#236
#236 = FACE_OUTER_BOUND ( 'NONE', #202, .T. ) ;