Splitting a file incrementally


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Splitting a file incrementally
# 1  
Old 03-23-2016
Splitting a file incrementally

Dear all,

I would like to split a file incrementally. My file looks like:

Code:
$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)
}
}
.
.
.

I would like to have files which have "path" incrementally.
The 1st file has the 1st path. The 2nd file has the 1st and 2nd paths. The 3rd file has the 1st, 2nd, and 3rd paths. This incremental splitting will be continued the end of the original file. (upto n).

P1:
Code:
$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:
Code:
$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:
Code:
$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)
}
}

Could you let me know how to do this job? Any language (sed,awk,grep) are okay to me.

Best,

Jaeyoung

Last edited by jypark22; 03-23-2016 at 06:40 PM..
# 2  
Old 03-23-2016
Hello jypark22,

Could you please try following and let me know if this helps you.
Code:
awk '/^\$path/{A++;if(A>0){print Q >> "P"A}} {if(A>=0){Q=Q?Q ORS $0:$0;}} END{A++;print Q > "P"A}' A=-1  Input_file

Thanks,
R. Singh
# 3  
Old 03-23-2016
Is this a homework assignment?

If it is not a homework assignment, please explain why it is useful to create three files containing (collectively) six copies of a sixteen lines of text from one file containing three identical copies of sixteen lines of text.
# 4  
Old 03-23-2016
Hi R. Singh,

Your code works perfectly. Thank you so much. I would appreciate your help.

- Don

It would be the inputs of the automatic test pattern generator. I will use files by Singh's code as an input of ATPG.

Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Splitting the file based on two fields - Fixed length file

Hi , I am having a scenario where I need to split the file based on two field values. The file is a fixed length file. ex: AA0998703000000000000190510095350019500010005101980301 K 0998703000000000000190510095351019500020005101480 ... (4 Replies)
Discussion started by: saj
4 Replies

2. Shell Programming and Scripting

Splitting a text file into smaller files with awk, how to create a different name for each new file

Hello, I have some large text files that look like, putrescine Mrv1583 01041713302D 6 5 0 0 0 0 999 V2000 2.0928 -0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 5.6650 0.2063 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 3.5217 ... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

3. Shell Programming and Scripting

Read files incrementally and search for particular string.

Example I have following requirements where i need to search for particular string from the log files.Files will be archived with number attached end to it and creates a new log file. First Day i will ran at 8:00 AM Filename:a.log1 Wed Aug 24 04:46:34... (1 Reply)
Discussion started by: nareshnani211
1 Replies

4. Shell Programming and Scripting

Linux command rsync sending files incrementally

Please, i have a question about rsync command: Here is the command that i have used in my script: rsync -ratlz --rsh="/usr/bin/sshpass ssh -o StrictHostKeyChecking=no" -aAXHltzh --progress --numeric-ids --devices --rsync-path="rsync" $1 $hostname:$1 using this command, i can... (0 Replies)
Discussion started by: chercheur111
0 Replies

5. Shell Programming and Scripting

Execution of loop :Splitting a single file into multiple .dat file

hdr=$(cut -c1 $path$file|head -1)#extract header”H” trl=$(cut -c|path$file|tail -1)#extract trailer “T” SplitFile=$(cut -c 50-250 $path 1$newfile |sed'$/ *$//' head -1')# to trim white space and extract table name If; then # start loop if it is a header While read I #read file Do... (4 Replies)
Discussion started by: SwagatikaP1
4 Replies

6. Shell Programming and Scripting

Splitting XML file on basis of line number into multiple file

Hi All, I have more than half million lines of XML file , wanted to split in four files in a such a way that top 7 lines should be present in each file on top and bottom line of should be present in each file at bottom. from the 8th line actual record starts and each record contains 15 lines... (14 Replies)
Discussion started by: ajju
14 Replies

7. Shell Programming and Scripting

Increase two numeric variables incrementally together

Hi, I was wondering if someone could help with what is probably a fairly easy problem. I have two variables, i is between 1-5, j is between 11-15 I'd like to produce this: 1_11 2_12 3_13 4_14 5_15 Each number goes up incrementally with the other. But my shoddy code is not... (5 Replies)
Discussion started by: hubleo
5 Replies

8. Shell Programming and Scripting

Splitting a file in to multiple files and passing each individual file to a command

I have an input file with contents like: MainFile.dat: 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 12247689|7896|77698080 16768900|hh78|78959390 ... (4 Replies)
Discussion started by: rkrish
4 Replies

9. Shell Programming and Scripting

how do you to add numbers incrementally?

I've refined the filesystem size using awk and directed to a file name. eg, here's the content in a file called "numbers" $cat numbers 345 543 23423456 44435 546 . . how do you write a script to all these numbers to get the total? thanks a lot. (9 Replies)
Discussion started by: kiem
9 Replies
Login or Register to Ask a Question