How to Print between ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Print between ?
# 1  
Old 06-19-2013
Wrench How to Print between ?

Hi All.

I want print log file.
I try :
Code:
cat filename |nawk  -F" " '{print $2,$3}'

but notwork.
Please Help me..

Code:
201922.Batch.batchbl.28528.f7728.AddVchr.S201306192014336016.872.ASS68848350.20033.20033: Front-end: Queue is full.KPI460.ASS68848350
201922.Offline.GWGW.23767.f7728.InqrSubrStat.S201306192019225009.1.ASS51546342.20033.20033: Front-end: Queue is full.KPI460.ASS51546342
201922.Offline.Offlinesb.27032.f7728.RqstSos.S201306192016486011.27.ASS51104165.20033.20033: Front-end: Queue is full.KPI460.ASS51104165
201922.Offline.Offlinesb.8860.f7728.RqstSos.S201306192016346009.33.ASD11275251.20033.20033: Front-end: Queue is full.KPI470.ASD11275251
201923.Offline.Offlinesb.24294.f7728.DoSnglSmapGetSubrSrvc.S201306192019227014.1.20033.20033: Front-end: Queue is full.KPI470.
201923.Offline.GWGW.24200.f7728.AddVchr.S201306192019227013.1.ASS36476547.20033.20033: Front-end: Queue is full.KPI470.ASS36476547
201923.Offline.Offlinesb.14206.f7728.RqstSos.S201306191846018012.1034.ASS50154989.20033.20033: Front-end: Queue is full.KPI460
201923.Offline.bltux.24730.f7728.InqrByAcctList.S201306192019238005.1.ASS88128068.20033.20033: Front-end: Queue is full.KPI460.ASS88128068
201923.Batch.batchbl.17153.f7728.AddVchr.S201306192015096008.832.ASS51527430.20033.20033: Front-end: Queue is full.KPI480.ASS51527430
201923.Offline.Offlinesb.24860.f7728.InqrPrpdWithMtplPckt.S201306192019236007.1.ASS46809394.20033.20033: Front-end: Queue is full.KPI460.ASS46809394
201923.Offline.Offlinesb.24937.f7728.InqrPrpdWithMtplPckt.S201306192019235008.1.ASS81208751.20033.20033: Front-end: Queue is full.KPI480


I want output
Code:
Front-end: Queue is full.KPI460
Front-end: Queue is full.KPI460
Front-end: Queue is full.KPI460
Front-end: Queue is full.KPI470
Front-end: Queue is full.KPI470
Front-end: Queue is full.KPI470
Front-end: Queue is full.KPI460
Front-end: Queue is full.KPI460
Front-end: Queue is full.KPI480
Front-end: Queue is full.KPI460
Front-end: Queue is full.KPI480

Thank You
# 2  
Old 06-19-2013
Try the cut command:-
Code:
cut -f2-3 -d " " filename

This should give you fields 2 to 3 from your file based on a space separator. If it's still not doing the right thing, are you sure that the gap in the records is a space?




Robin
# 3  
Old 06-19-2013
Code:
nawk '{gsub(/.*[0-9]: |\.$|\.A.*/,x)}1' file

# 4  
Old 06-19-2013
Try:
Code:
sed 's/[^:]*: \([^.]*\.[^.]*\).*/\1/' file

-or-

Code:
awk -F': ' '{split($3,F,/\./); print $2 FS F[1]"."F[2]}' file


Last edited by Scrutinizer; 06-19-2013 at 12:08 PM..
# 5  
Old 06-20-2013
Answer

Hello,

Could you please use the following code and try the same.
Let us assume te2 is the file which have the data as mentioned by you in thread above.


code:
Code:
 
$ awk -F "20033.20033:" '{print$2}' te2 | awk -F. '{print$1 $2}'
 
 
Front-end: Queue is fullKPI460
Front-end: Queue is fullKPI460
Front-end: Queue is fullKPI460
Front-end: Queue is fullKPI470
Front-end: Queue is fullKPI470
Front-end: Queue is fullKPI470
Front-end: Queue is fullKPI460
Front-end: Queue is fullKPI460
Front-end: Queue is fullKPI480
Front-end: Queue is fullKPI460
Front-end: Queue is fullKPI480
$

Thanks,
R. Singh

Last edited by Scrutinizer; 06-20-2013 at 06:47 AM.. Reason: icode tags to code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Setting up Solaris 10 to print to a windows print server

Guys, I have a issue that I am trying to rectify please advise. lpstat -t shows scheduler is running printer lext644 disabled since Mon Dec 02 19:48:18 2013. available.I have restarted the printer service and it shows online but the above says disabled. I have a lot of jobs in the print... (1 Reply)
Discussion started by: terrywhitejr
1 Replies

2. UNIX for Dummies Questions & Answers

How to create a print filter that print text & image?

Currently, I have a print filter that takes a text file, that convert it into PCL which then gets to a HP printer. This works. Now I need to embedded a image file within the text file. I'm able to convert the image file into PCL and I can cat both files together to into a single document... (1 Reply)
Discussion started by: chedlee88-1
1 Replies

3. UNIX for Advanced & Expert Users

[Solved] remove all print jobs from a print queue

Hello, Sometimes i need to clear all the jobs of a print queue and it is really annoying to cancel one by one. Is there a way to cancel all print jobs for a specific print queue with a single command instead of cancelling them one by one? My AIX system is 5.3 Thank you for your attention (2 Replies)
Discussion started by: omonoiatis9
2 Replies

4. Shell Programming and Scripting

print first few lines, then apply regex on a specific column to print results.

abc.dat tty cpu tin tout us sy wt id 0 0 7 3 19 71 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 0.0 133.2 0.0 682.9 0.0 1.0 0.0 7.2 0 79 c1t0d0 0.2 180.4 0.1 5471.2 3.0 2.8 16.4 15.6 15 52 aaaaaa1-xx I want to skip first 5 line... (4 Replies)
Discussion started by: kchinnam
4 Replies

5. Shell Programming and Scripting

print lines AFTER lines cointaining a regexp (or print every first and fourth line)

Hi all, This should be very easy but I can't figure it out... I have a file that looks like this: @SRR057408.1 FW8Y5CK02R652T length=34 AGCAGTGGTATCAACGCAGAGTAAGCAGTGGTAT +SRR057408.1 FW8Y5CK02R652T length=34 FIIHFF6666?=:88@@@BBD:::?@ABBAAA>8 @SRR057408.2 FW8Y5CK02TBMHV length=52... (1 Reply)
Discussion started by: kmkocot
1 Replies

6. Shell Programming and Scripting

Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction? for FILE in `cat list`; do if ; then ... (1 Reply)
Discussion started by: overkill
1 Replies

7. Solaris

Print to ps2pdf print queue

I am trying to create a printer queue, on a SunOS 5.7 system, that outputs a pdf file. There is an application running on the system that has a print button, which sends print files to the default printer. If I disable the printer, I am able to manually capture the files in /var/spool/lp/tmp and... (2 Replies)
Discussion started by: Sean_69
2 Replies

8. UNIX for Dummies Questions & Answers

Print to a ps2pdf print queue.

I am trying to create a printer queue, on a SunOS 5.7 system, that outputs a pdf file. There is an application running on the system that has a print button, which sends print files to the default printer. If I disable the printer, I am able to manually capture the files in /var/spool/lp/tmp and... (1 Reply)
Discussion started by: Sean_69
1 Replies

9. HP-UX

Print Problem in UNIX. Need to know the option to specify the print paper size

Hi, Could any one please let me know what is the option available in UNIX to print by specifying the paper size? We are using Unix11i. I could n't see any option specified in the 'lp' command to print the report by specifying the size of the paper. It would be of great help to me, if... (1 Reply)
Discussion started by: ukarthik
1 Replies

10. Shell Programming and Scripting

How do I get awk to print a " in it's print part?

The line is simple, use " '{ print $1"]"$2"\"$3THE " NEEDS TO GO HERE$4 }' I've tried \", "\, ^" and '"" but none of it works. What am I missing? Putting in the [ between $1 and $2 works fine, I just need to do the same with a ". Thanks. (2 Replies)
Discussion started by: LordJezo
2 Replies
Login or Register to Ask a Question