Sponsored Content
Top Forums UNIX for Dummies Questions & Answers grep within certain part of file Post 302147250 by radoulov on Monday 26th of November 2007 05:06:00 AM
Old 11-26-2007
Quote:
Also, is it possible to cut this file into chunk. The delimiter would be the "ERROR 123 detected."
Each chunk of file will be put into a new file.
Something like this:

Code:
awk '/ERROR [0-9]* detected/{close(f);f=($4"_"$5"_"++c".out")}f{print>f}' filename

Use nawk on Solaris.


Quote:
Now, I only want to get a certain part on the file.. say the part

11/16 14:09:49.8452 --- Generating a <reading> event
11/16 14:09:50.0868 ---- Sending a <writing> event
11/16 16:10:51.6707 --- Generating a <reading> event
11/16 16:10:52.3232 ---- Sending a <writing> event
11/16 16:08:19.5436 --- Generating a <reading> event
11/16 16:08:19.7784 ---- Sending a <writing> event

which is after the 2nd "ERROR 123 detected." line. Then put it in a file.

Code:
awk '/ERROR [0-9]* detected/{++c};c==2' filename>second_error.out

Use nawk or /usr/xpg4/bin/awk on Solaris.

Last edited by radoulov; 11-26-2007 at 06:12 AM.. Reason: need more coffee :)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep part of file name

Hi, I have a problem to use grep in my script . If I want to grep the file for example : PTWO9089.txt The code below works . grep ^PONE But, I dont know on how to grep the file like this 9066PTWO.txt I'll try to use this code : grep PTWO^ ,but it doesn't work. For your info, the... (4 Replies)
Discussion started by: badbunny9316
4 Replies

2. UNIX for Dummies Questions & Answers

How to use grep to get only part of a line...

Hello All. I have an output file which contains the phrase "Total DFT Energy =" and then a number. This occurs many times in the output file, and what I want is to pipe the numbers (which are all different) to a file so I can plot them. How do I grep "Total DFT Energy =" and then get the numbers... (3 Replies)
Discussion started by: EinsteinMcfly
3 Replies

3. Shell Programming and Scripting

How to get a part of the line(need help in using grep)

Hi, Suppose, DBconnection=jdbc: oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.x)(PORT=YYYY))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=project_db1))) This is a part of a file <filename> . I Need to get the value of SERVICE_NAME from this line… The... (4 Replies)
Discussion started by: Dpu
4 Replies

4. UNIX for Dummies Questions & Answers

can I grep a part of one line ?

<exp code="12556a" message="ok, fine4" displayMessage="jksdfj ksd" \> <exp code="123456a" message="ok, 2fine" displayMessage="jksdfj ksd" \> <exp code="12dfgda" message="1ok, fine" displayMessage="jksdfj ksd" \> now I want to cut code attribute and message attribute, such as ... (2 Replies)
Discussion started by: vincent_W
2 Replies

5. Shell Programming and Scripting

[awk] grep a part of filename as entry file

hi all, i need to combine these files into one csv file. Bounce_Mail_Event_Daily_Report_01_Jul_2012.csv Bounce_Mail_Event_Daily_Report_02_Jul_2012.csv Bounce_Mail_Event_Daily_Report_03_Jul_2012.csv Bounce_Mail_Event_Daily_Report_04_Jul_2012.csv... (10 Replies)
Discussion started by: makan
10 Replies

6. Shell Programming and Scripting

[Solved] Printing a part of the last line of the specific part of a file

Hi, I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this: Name =A xxxxxx yyyyyy zzzzzz aaaaaa bbbbbb Value = 57 This is necessary because in a file there are written more lines which... (6 Replies)
Discussion started by: wenclu
6 Replies

7. Shell Programming and Scripting

Grep a part of file based on string identifiers

consider below file contents cat myOutputFIle.txt 8 CCM-HQE-ResourceHealthCheck: Resource List : No RED/UNKNOWN resource Health entries found ---------------------------------------------------------- 9 CCM-TraderLogin-Status: Number of logins: 0... (4 Replies)
Discussion started by: vivek d r
4 Replies

8. UNIX for Dummies Questions & Answers

Grep a part of a line from a file

Hi, I have a file with thousands of lines as below INSERT INTO T_DIM_CLNT(CLNT_KY,CLNT_OBJ_ID,ISI_CLNT_ID,OPERN_ID,CLNT_NM,PRMRY_SIC_CD,PRMRY_SIC_DSC,RET_AGE_NBR,REC_CRT_TS,REC_DATA_EXTRC_TS,ETL_LOG_KY) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)... (5 Replies)
Discussion started by: sudhakar T
5 Replies

9. UNIX for Beginners Questions & Answers

Grep a section from an UNIX file obtaining only part of the data

Hello, I have a log file that has several sections "BEGIN JOB, End of job" like in the following example: 19/06/12 - 16:00:57 (27787398-449294): BEGIN JOB j1(27787398-449294) JOB1 19/06/12 - 16:00:57 (27787398-449294): DIGIT: 0 number of present logs : 1 19/06/12 - 16:00:57... (4 Replies)
Discussion started by: mvalonso
4 Replies

10. UNIX for Beginners Questions & Answers

How to make a loop to read the input from a file part by part?

Hi All, We've a VDI infrastructure in AWS (AWS workspaces) and we're planning to automate the process of provisioning workspaces. Instead of going to GUI console, and launching workspaces by selecting individual users is little time consuming. Thus, I want to create them in bunches from AWS CLI... (6 Replies)
Discussion started by: arun_adm
6 Replies
ldi_ev_get_type(9F)					   Kernel Functions for Drivers 				       ldi_ev_get_type(9F)

NAME
ldi_ev_get_type - get event name string from event cookie SYNOPSIS
#include <sys/sunldi.h> int ldi_ev_get_type(ldi_ev_cookie_t cookie); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI) PARAMETERS
ldi_ev_cookie_t cookie An opaque event cookie for the event type returned by a previous call to ldi_ev_get_cookie(9F). DESCRIPTION
The ldi_ev_get_type() function returns the event string represented by the LDI event cookie "cookie". RETURN VALUES
On success, this function returns the event string represented by "cookie". On failure, this function returns NULL. CONTEXT
This function can be called from user and kernel contexts only. SEE ALSO
ldi_ev_get_cookie(9F), ldi_ev_register_callbacks(9F), ldi_ev_remove_callbacks(9F) SunOS 5.11 21 Aug 2007 ldi_ev_get_type(9F)
All times are GMT -4. The time now is 04:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy