The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 10-04-2006
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,557
Alternative in Python:

Input:
blah
xxx
yyy
**********************************************************
** 05T00NPQSMR1 P98P2234 Tue 10 03 09:57:24 2006
** dibid= 1166 testerid= 6
** sample= 100 0
** tasM= MFMM xx xx xx
** tasC= MFMC xx xx xx
************************************
xxxx
yyy
zzz
blah
blah
**********************************************************
** 05T00NPQSMR1 P98P2234 Tue 10 03 09:57:24 2006
** dibid= 1166 testerid= 6
** sample= 100 0
** tasM= MFMM xx xx xx
** tasC= MFMC xx xx xx
************************************
xxxasdfljsdlfx
yyy;slkfd;s
zzzsdklfjsd
blasdflksdjh
blajaspofkspodf




Code:
number = []
all = open("test.txt").readlines()
for num,line in enumerate(all):
 	line = line.strip()
 	if "*" * 58 in line:
 		number.append(num)
 

for i in range(len(number)):
 	try:
 		print ''.join(all[ number[i]:number[i+1] ] )
 	except:
 		print ''.join(all[number[i]:])


Output:
**********************************************************
** 05T00NPQSMR1 P98P2234 Tue 10 03 09:57:24 2006
** dibid= 1166 testerid= 6
** sample= 100 0
** tasM= MFMM xx xx xx
** tasC= MFMC xx xx xx
************************************
xxxx
yyy
zzz
blah
blah

**********************************************************
** 05T00NPQSMR1 P98P2234 Tue 10 03 09:57:24 2006
** dibid= 1166 testerid= 6
** sample= 100 0
** tasM= MFMM xx xx xx
** tasC= MFMC xx xx xx
************************************
xxxasdfljsdlfx
yyy;slkfd;s
zzzsdklfjsd
blasdflksdjh
blajaspofkspodf

Last edited by ghostdog74; 10-05-2006 at 04:34 AM..