2016-03-23 16 views
0

Ich möchte eine Datei inkrementell aufteilen. Meine Datei sieht so aus:Eine Datei inkrementell teilen

$path { 
$name "path_sparc_ifu_dec_1" ; 
$transition { 
"dtu_inst_d[22]" v ; // (in) 
"U622/Y" ^ ; // (INVX16_LVT) 
"U870/Y" ^ ; // (AND2X1_LVT) 
"U873/Y" v ; // (INVX1_LVT) 
"U872/Y" ^ ; // (NAND3X0_LVT) 
"U1045/Y" v ; // (NAND3X0_LVT) 
"U1046/Y" ^ ; // (NAND3X0_LVT) 
"U1063/Y" ^ ; // (OR3X1_LVT) 
"U1092/Y" ^ ; // (OR3X1_LVT) 
"U1095/Y" ^ ; // (OA21X1_LVT) 
"illinste_ff_q_reg_0_/D" ^ ; // (DFFX1_LVT) 
} 
} 
$path { 
$name "path_sparc_ifu_dec_2" ; 
$transition { 
"dtu_inst_d[22]" ^ ; // (in) 
"U622/Y" v ; // (INVX16_LVT) 
"U870/Y" v ; // (AND2X1_LVT) 
"U873/Y" ^ ; // (INVX1_LVT) 
"U872/Y" v ; // (NAND3X0_LVT) 
"U1045/Y" ^ ; // (NAND3X0_LVT) 
"U1046/Y" v ; // (NAND3X0_LVT) 
"U1063/Y" v ; // (OR3X1_LVT) 
"U1092/Y" v ; // (OR3X1_LVT) 
"U1095/Y" v ; // (OA21X1_LVT) 
"illinste_ff_q_reg_0_/D" v ; // (DFFX1_LVT) 
} 
} 
$path { 
$name "path_sparc_ifu_dec_3" ; 
$transition { 
"dtu_inst_d[22]" v ; // (in) 
"U622/Y" ^ ; // (INVX16_LVT) 
"U782/Y" ^ ; // (AND2X1_LVT) 
"U781/Y" ^ ; // (AND2X1_LVT) 
"U632/Y" v ; // (INVX0_LVT) 
"U999/Y" ^ ; // (NAND4X0_LVT) 
"U1000/Y" v ; // (NAND2X0_LVT) 
"U1006/Y" ^ ; // (NAND4X0_LVT) 
"U1007/Y" ^ ; // (AND4X1_LVT) 
"prope_ff_q_reg_0_/D" ^ ; // (DFFX1_LVT) 
} 
} 
. 
. 
. 

Ich möchte Dateien haben, die "Pfad" inkrementell haben. Die 1. Datei hat den 1. Pfad. Die 2. Datei hat den 1. und 2. Pfad. Die 3. Datei hat den 1., 2. und 3. Pfad. Diese inkrementelle Aufteilung wird am Ende der ursprünglichen Datei fortgesetzt. (bis n).

P1:

$path { 
$name "path_sparc_ifu_dec_1" ; 
$transition { 
"dtu_inst_d[22]" v ; // (in) 
"U622/Y" ^ ; // (INVX16_LVT) 
"U870/Y" ^ ; // (AND2X1_LVT) 
"U873/Y" v ; // (INVX1_LVT) 
"U872/Y" ^ ; // (NAND3X0_LVT) 
"U1045/Y" v ; // (NAND3X0_LVT) 
"U1046/Y" ^ ; // (NAND3X0_LVT) 
"U1063/Y" ^ ; // (OR3X1_LVT) 
"U1092/Y" ^ ; // (OR3X1_LVT) 
"U1095/Y" ^ ; // (OA21X1_LVT) 
"illinste_ff_q_reg_0_/D" ^ ; // (DFFX1_LVT) 
} 
} 

P2:

$path { 
$name "path_sparc_ifu_dec_1" ; 
$transition { 
"dtu_inst_d[22]" v ; // (in) 
"U622/Y" ^ ; // (INVX16_LVT) 
"U870/Y" ^ ; // (AND2X1_LVT) 
"U873/Y" v ; // (INVX1_LVT) 
"U872/Y" ^ ; // (NAND3X0_LVT) 
"U1045/Y" v ; // (NAND3X0_LVT) 
"U1046/Y" ^ ; // (NAND3X0_LVT) 
"U1063/Y" ^ ; // (OR3X1_LVT) 
"U1092/Y" ^ ; // (OR3X1_LVT) 
"U1095/Y" ^ ; // (OA21X1_LVT) 
"illinste_ff_q_reg_0_/D" ^ ; // (DFFX1_LVT) 
} 
} 
$path { 
$name "path_sparc_ifu_dec_2" ; 
$transition { 
"dtu_inst_d[22]" ^ ; // (in) 
"U622/Y" v ; // (INVX16_LVT) 
"U870/Y" v ; // (AND2X1_LVT) 
"U873/Y" ^ ; // (INVX1_LVT) 
"U872/Y" v ; // (NAND3X0_LVT) 
"U1045/Y" ^ ; // (NAND3X0_LVT) 
"U1046/Y" v ; // (NAND3X0_LVT) 
"U1063/Y" v ; // (OR3X1_LVT) 
"U1092/Y" v ; // (OR3X1_LVT) 
"U1095/Y" v ; // (OA21X1_LVT) 
"illinste_ff_q_reg_0_/D" v ; // (DFFX1_LVT) 
} 
} 

P3:

$path { 
$name "path_sparc_ifu_dec_1" ; 
$transition { 
"dtu_inst_d[22]" v ; // (in) 
"U622/Y" ^ ; // (INVX16_LVT) 
"U870/Y" ^ ; // (AND2X1_LVT) 
"U873/Y" v ; // (INVX1_LVT) 
"U872/Y" ^ ; // (NAND3X0_LVT) 
"U1045/Y" v ; // (NAND3X0_LVT) 
"U1046/Y" ^ ; // (NAND3X0_LVT) 
"U1063/Y" ^ ; // (OR3X1_LVT) 
"U1092/Y" ^ ; // (OR3X1_LVT) 
"U1095/Y" ^ ; // (OA21X1_LVT) 
"illinste_ff_q_reg_0_/D" ^ ; // (DFFX1_LVT) 
} 
} 
$path { 
$name "path_sparc_ifu_dec_2" ; 
$transition { 
"dtu_inst_d[22]" ^ ; // (in) 
"U622/Y" v ; // (INVX16_LVT) 
"U870/Y" v ; // (AND2X1_LVT) 
"U873/Y" ^ ; // (INVX1_LVT) 
"U872/Y" v ; // (NAND3X0_LVT) 
"U1045/Y" ^ ; // (NAND3X0_LVT) 
"U1046/Y" v ; // (NAND3X0_LVT) 
"U1063/Y" v ; // (OR3X1_LVT) 
"U1092/Y" v ; // (OR3X1_LVT) 
"U1095/Y" v ; // (OA21X1_LVT) 
"illinste_ff_q_reg_0_/D" v ; // (DFFX1_LVT) 
} 
} 
$path { 
$name "path_sparc_ifu_dec_3" ; 
$transition { 
"dtu_inst_d[22]" v ; // (in) 
"U622/Y" ^ ; // (INVX16_LVT) 
"U782/Y" ^ ; // (AND2X1_LVT) 
"U781/Y" ^ ; // (AND2X1_LVT) 
"U632/Y" v ; // (INVX0_LVT) 
"U999/Y" ^ ; // (NAND4X0_LVT) 
"U1000/Y" v ; // (NAND2X0_LVT) 
"U1006/Y" ^ ; // (NAND4X0_LVT) 
"U1007/Y" ^ ; // (AND4X1_LVT) 
"prope_ff_q_reg_0_/D" ^ ; // (DFFX1_LVT) 
} 
} 

Können Sie mir mitteilen, wie diese Arbeit zu tun? Jede Sprache (sed, awk, grep) ist in Ordnung für mich.

Best,

Jaeyoung

Antwort

0

würde ich awk verwenden. Sie können mit dem Datensatztrennzeichen, wie diese spielen:

awk '{file="P"NR".txt";print > file;close(file)}' RS='}\n}\n' ORS='}\n}\n' file 
0

gawk zur Rettung!

$ awk -v RS="\n}\n}" 'NR==1{term=RT} 
          {a[NR]=$0} 
      END{for(i=1;i<NR;i++) 
        for(k=1;k<=i;k++) 
        print a[k] term > FILENAME"_"i}' file 
Verwandte Themen