Pattern extract Shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pattern extract Shell
# 1  
Old 06-06-2014
Wrench Pattern extract Shell

Code:
2014-05-31-18.22.18.500158-240 E11115478A502      LEVEL: Info
PID     : 25100668             TID  : 73282       PROC : db2sysc 0
INSTANCE: udbin001             NODE : 000         DB   : IBDSYS01
APPHDL  : 0-18345              APPID: *LOCAL.udbin001.140531200018
AUTHID  : udbin001
EDUID   : 73282                EDUNAME: db2agent (IBGPM01P) 0
FUNCTION: DB2 UDB, database utilities, sqluxLogDataStats, probe:312
MESSAGE : Actual size of backup in bytes:
DATA #1 : unsigned integer, 8 bytes
175023153152

2014-06-01-11.58.08.193212-240 E11131215A503      LEVEL: Info
PID     : 25100668             TID  : 66744       PROC : db2sysc 0
INSTANCE: udbin001             NODE : 000         DB   : IBDSYS01
APPHDL  : 0-13715              APPID: *LOCAL.udbin001.140601130013
AUTHID  : udbin001
EDUID   : 66744                EDUNAME: db2agent (IBGPM01P) 0
FUNCTION: DB2 UDB, database utilities, sqluxLogDataStats, probe:312
MESSAGE : Actual size of backup in bytes:
DATA #1 : unsigned integer, 8 bytes
3378060292096

2014-06-02-18.21.43.195977-240 E11542845A501      LEVEL: Info
PID     : 25100668             TID  : 74822       PROC : db2sysc 0
INSTANCE: udbin001             NODE : 000         DB   : IBDSYS02
APPHDL  : 0-41425              APPID: *LOCAL.udbin001.140602200006
AUTHID  : udbin001
EDUID   : 74822                EDUNAME: db2agent (IBGPM01P) 0
FUNCTION: DB2 UDB, database utilities, sqluxLogDataStats, probe:312
MESSAGE : Actual size of backup in bytes:
DATA #1 : unsigned integer, 8 bytes
34234567898

I'm looking for o/p like this
Code:
2014-05-31-18.22,udbin001,IBDSYS01,175023153152
2014-06-01-11.58,udbin001,IBDSYS01,3378060292096
2014-06-02-18.21,udbin001,IBDSYS02,34234567898

FYI : I already got an answer on another thread. I just need to finalize this. Kindly help me.

Last edited by Scott; 06-06-2014 at 07:21 PM.. Reason: Code tags
# 2  
Old 06-06-2014
Since you might want to change pieces that you want to show in the future again, I'll tell you one way of doing it.

This first line will show you the break down of a record
Code:
awk 'BEGIN{ FS="[. :\n]"; RS="" } NR==1{for(i=1; i<=NF; i++) {print i,$i}}'

Just place an extra "%s" in the printf and use the number shown of the data piece you want in the printf place holder.

example:
At this time you wanted piece 1, 2, 24, 32 and last one which is $NF or 82

Code:
awk 'BEGIN{ FS="[. :\n]"; RS="" } {printf("%s.%s,%s,%s,%s\n", $1,$2,$24,$32,$NF)}' file

There are other ways of doing it, but this might help you to help yourself.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract whole word preceding a specific character pattern with first occurence of the pattern

Hello. Here is a file contents : declare -Ax NEW_FORCE_IGNORE_ARRAY=(="§" ="§" ="§" ="§" ="§" .................. ="§"Here is a pattern =I want to extract 'NEW_FORCE_IGNORE_ARRAY' which is the whole word before the first occurrence of pattern '=' Is there a better solution than mine :... (3 Replies)
Discussion started by: jcdole
3 Replies

2. UNIX for Beginners Questions & Answers

Help with pattern match and Extract

Hi All, I am having a file like below . Basically when SB comes in the text with B. I have to take the word till SB. When there only B I should take take till B. Tried for cut it by demilter but not able to build the logic SB- CD B_RESTO SB_RESTO CRYSTALS BOILERS -->There SB and B so I... (6 Replies)
Discussion started by: arunkumar_mca
6 Replies

3. Shell Programming and Scripting

Need pattern Extract

2014-05-31-18.22.18.500158-240 E11115478A502 LEVEL: Info PID : 25100668 TID : 73282 PROC : db2sysc 0 INSTANCE: udbin001 NODE : 000 DB : APPHDL : 0-18345 APPID: *LOCAL.udbin001.140531200018 AUTHID : udbin001 EDUID : 73282 ... (4 Replies)
Discussion started by: ilugopal
4 Replies

4. Shell Programming and Scripting

Search for a pattern,extract value(s) from next line, extract lines having those extracted value(s)

I have hundreds of files to process. In each file I need to look for a pattern then extract value(s) from next line and then search for value(s) selected from point (2) in the same file at a specific position. HEADER ELECTRON TRANSPORT 18-MAR-98 1A7V TITLE CYTOCHROME... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies

5. Shell Programming and Scripting

Extract pattern before two newlines

Hi All, My file looks like this: 1 2 3 3 4 5 6 7 8 8 7 6 3 4 5 3 6 7 3 4 5 1 2 4 3 4 6 2 4 6 As you can see there are two newlines after the next pattern of numbers begin. (4 Replies)
Discussion started by: shoaibjameel123
4 Replies

6. Shell Programming and Scripting

Extract a pattern from file

In my file I have a pattern ri="234" value of ri can be any i want to find this pattern in file replace this value of ri with another value stored in some variable say newri Please tell how to do it? Thanks in Advance (10 Replies)
Discussion started by: pasricha.kunal
10 Replies

7. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

8. Shell Programming and Scripting

pattern extract

Hi I have a pattern like : SYSTEM_NAME-232-S7-200810060949.LOG Here I need to extract system name and the timestamp and also the numeric number after "-S" i.e 7 here . I am not very sure of whether I should use sed / awk for this ?:confused: Thanks, Priya. (6 Replies)
Discussion started by: priyam
6 Replies

9. HP-UX

extract field of characters after a specific pattern - using UNIX shell script

Hello, Below is my input file's content ( in HP-UX platform ): ABCD120672-B21 1 ABCD142257-002 1 ABCD142257-003 1 ABCD142257-006 1 From the above, I just want to get the field of 13 characters that comes after 'ABCD' i.e '120672-B21'... . Could... (2 Replies)
Discussion started by: jansat
2 Replies

10. UNIX for Dummies Questions & Answers

Extract the Pattern

Hello All, can anyone help me out in extracting the pattern from a file... The Input file is: NFS B.11.11 ONC/NFS; Network-FileSystem,InformationServices,Utilities|123 NParProvider B.11.11.01.04.01.01 nPartition Provider|456 NPartition A.01.02 Enhanced NPartition Commands/789... (6 Replies)
Discussion started by: aajan
6 Replies
Login or Register to Ask a Question