awk using sub , filtering textfile


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk using sub , filtering textfile
# 8  
Old 11-21-2012
Code:
CMF_COMP_ELEM_GSM2_B71.WORLD_20121114130908.log   107496444 rows inserted into ALL_S1_CMF_COMP_ELEM.
CMF_COMP_ELEM_GSM3_B71.WORLD_20121114130908.log   110729006 rows inserted into ALL_S1_CMF_COMP_ELEM.
CMF_COMP_ELEM_GSM4_B71.WORLD_20121114130908.log   92549475 rows inserted into ALL_S1_CMF_COMP_ELEM.
CMF_COMP_ELEM_GSM5_B71.WORLD_20121114130908.log   35606251 rows inserted into ALL_S1_CMF_COMP_ELEM.
DDL_KKR_CSK_GSM2_B71.WORLD_20121114130908.log   107496444 rows inserted into ALL_S1_DDL_KKR_CSK.
DDL_KKR_CSK_GSM3_B71.WORLD_20121114130908.log   110729006 rows inserted into ALL_S1_DDL_KKR_CSK.
DDL_KKR_CSK_GSM4_B71.WORLD_20121114130908.log   92549475 rows inserted into ALL_S1_DDL_KKR_CSK.
DDL_KKR_CSK_GSM5_B71.WORLD_20121114130908.log   35606251 rows inserted into ALL_S1_DDL_KKR_CSK.

lets say i have a text as abve, i want a line between CMF and DDL logs.... how can i do it ? .... no substitute just separation line is required

---------- Post updated at 07:43 PM ---------- Previous update was at 07:42 PM ----------

Code:
expedted output :


CMF_COMP_ELEM_GSM2_B71.WORLD_20121114130908.log   107496444 rows inserted into ALL_S1_CMF_COMP_ELEM.
CMF_COMP_ELEM_GSM3_B71.WORLD_20121114130908.log   110729006 rows inserted into ALL_S1_CMF_COMP_ELEM.
CMF_COMP_ELEM_GSM4_B71.WORLD_20121114130908.log   92549475 rows inserted into ALL_S1_CMF_COMP_ELEM.
CMF_COMP_ELEM_GSM5_B71.WORLD_20121114130908.log   35606251 rows inserted into ALL_S1_CMF_COMP_ELEM.
========================================================================================================
DDL_KKR_CSK_GSM2_B71.WORLD_20121114130908.log   107496444 rows inserted into ALL_S1_DDL_KKR_CSK.
DDL_KKR_CSK_GSM3_B71.WORLD_20121114130908.log   110729006 rows inserted into ALL_S1_DDL_KKR_CSK.
DDL_KKR_CSK_GSM4_B71.WORLD_20121114130908.log   92549475 rows inserted into ALL_S1_DDL_KKR_CSK.
DDL_KKR_CSK_GSM5_B71.WORLD_20121114130908.log   35606251 rows inserted into ALL_S1_DDL_KKR_CSK.

# 9  
Old 11-22-2012
Code:
awk '{print $0 ~ /DDL/ && p==1 || $0 ~ /CMF/ && p==2?s"\n"$0:$0;p=0}{p=$0 ~ /CMF/?1:2}' s="====="  infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to separate sorte different characters from one textfile and copy them in a new textfile?

My first post, so don't kill me :) Say i open some textfile with some example like this. on the table are handy, bread and wine Now i know exactly what is in and i want to separate and sorted it in terminal to an existing file with another 2 existing lines in like this: table plane ... (3 Replies)
Discussion started by: schwatter
3 Replies

2. Shell Programming and Scripting

awk print in one line after reading textfile with paragraphs

Hello everybody I have a text file which has the following format: nmm "text20140601.033954text" "text" "text" "text" , ... , "text" "text" , ... , Lat 36.3247 Lon 16.0588 Depth 8 "text", ... , "text" "text", ..., CovXX 1.65 CovYY 2.32 CovZZ 1.2 "text" , ..., "text nmm ... (6 Replies)
Discussion started by: phaethon
6 Replies

3. Shell Programming and Scripting

Variable filtering in awk

Hello all, can you explain why this filter does not work, it prints all the lines in the file: awk -v sel="TestString" 'sel' file while these work: awk '/TestString/' file awk -v sel="TestString" '$0~sel' file Thanks!:) (6 Replies)
Discussion started by: gio001
6 Replies

4. Shell Programming and Scripting

awk data filtering

I am trying to filter out some data with awk. If someone could help me that would be great. Below is my input file. Date: 10-JUN-12 12:00:00 B 0: 00 00 00 00 10 00 16 28 B 120: 00 00 00 39 53 32 86 29 Date: 10-JUN-12 12:00:10 B 0: 00 00 00 00 10 01 11 22 B 120: 00 00 00 29 23 32 16 29... (5 Replies)
Discussion started by: thibodc
5 Replies

5. Shell Programming and Scripting

filtering a numeric value which has '%' using awk

Hello Gurus, I have a requirement where I have to filter a value from some field which has 99% or greater than '99%'.. For ex: The Date (file -- sample.csv) will be like below Field1,Field2,Field3,Field4 860440512,844284992,16155520,99% 860440512,844284992,16155520,94%... (4 Replies)
Discussion started by: raghu.iv85
4 Replies

6. Shell Programming and Scripting

filtering with awk

i have question about awk ex: input.txt 1252468812,yahoo,3.5 1252468812,hotmail,2.4 1252468819,yahoo,1.2 msn,1252468812,8.9 1252468923,gmail,12 live,1252468812,3.4 yahoo,1252468812,9.0 1252468929,msn,1.2 output.txt 1252468812,yahoo,3.5 1252468812,hotmail,2.4 msn,1252468812,8.9... (3 Replies)
Discussion started by: zvtral
3 Replies

7. Shell Programming and Scripting

awk search strings from array in textfile

I am wanting to take a list of strings and loop through a list of textfiles to find matches. Preferably with awk and parsing the search strings into an array. // Search_strings.txt tag string dummy stuff things // List of files to search in textfile1.txt textfile2.txt The... (6 Replies)
Discussion started by: sdf
6 Replies

8. Shell Programming and Scripting

awk and sed filtering

Goo afternoon Sir'sould like to ask your help reagrding in this scenario using sed and awk. ******************************************************** Host:CDRMSAPPS1 Operating System:Linux 2.6.9-42.ELsmp Machine Type:UNIX Host Type:Client Version:5.1... (2 Replies)
Discussion started by: invinzin21
2 Replies

9. UNIX for Advanced & Expert Users

awk filtering ?

I have a Ques. Regarding awk I have few strings in a file, like.. ABC DEF_ABC GHI_ABC GHI Now I want string which has only 'ABC', not the part of any other string as it is also present in 'DEF_ABC' Output should be ABC Please guide me asap !! Thanks :b: (4 Replies)
Discussion started by: varungupta
4 Replies

10. UNIX for Advanced & Expert Users

formatting textfile inside ksh script using awk not working

I cannot seem to get this text file to format. Its as if the awk statement is being treated as a simple cat command. I manned awk and it was very confusing. I viewed previous posts on this board and I got the same results as with the the awk command statement shown here. Please help. ... (6 Replies)
Discussion started by: tekline
6 Replies
Login or Register to Ask a Question