Sponsored Content
Top Forums Shell Programming and Scripting Pattern Matching and creating output Post 302969262 by Chubler_XL on Sunday 20th of March 2016 06:56:14 PM
Old 03-20-2016
How about this:

Code:
awk -F "[ \\\]]*" '
function difftime(st,et) {
   split(st,sa,":")
   split(et,ea,":")
   return "(" ea[1]*3600-sa[1]*3600 + ea[2]*60-sa[2]*60 + ea[3]-sa[3] " seconds)"
}
/Task: / { T=$NF; gsub(/['\'':]*$/,"",T) }
/Phase .*started/ { TL[T];TS[T,$5]=$3}
/Phase .*ended/ { TE[T,$5]=$3}
END{
  for(task in TL) {
      print task
      for(phase=0; (task SUBSEP phase) in TS; phase++) {
         if((task SUBSEP phase) in TE)
         print "Phase " phase, TS[task,phase], TE[task,phase],\
               difftime(TS[task,phase],TE[task,phase])
         else print "Phase " phase, TS[task,phase], "Unfinished"
      }
  }
} ' OFS=" " infile


Output:
Code:
CIE
Phase 0 03:04:56 Unfinished
Phase 1 03:04:58 Unfinished
Phase 2 03:05:07 03:05:16 (9 seconds)
Phase 3 03:05:23 03:05:25 (2 seconds)
Phase 4 03:05:27 03:05:31 (4 seconds)
UBA
Phase 0 03:05:12 03:05:19 (7 seconds)
Phase 1 03:05:20 03:05:21 (1 seconds)
Phase 2 03:05:29 03:05:32 (3 seconds)

This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

2. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

Hi all, I'm looking for some help. I have a file (very long) that is organized like below: >Cluster 0 0 283nt, >01_FRYJ6ZM12HMXZS... at +/99% 1 279nt, >01_FRYJ6ZM12HN12A... at +/99% 2 281nt, >01_FRYJ6ZM12HM4TS... at +/99% 3 283nt, >01_FRYJ6ZM12HM946... at +/99% 4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies

3. Shell Programming and Scripting

sed - matching pattern one but not pattern two

All, I have the following file: -------------------------------------- # # /etc/pam.d/common-password - password-related modules common to all services # # This file is included from other service-specific PAM config files, # and should contain a list of modules that define the services... (2 Replies)
Discussion started by: RobertBerrie
2 Replies

4. Shell Programming and Scripting

Creating number by pattern matching

I have a certain mnemonic string from which I want to calculate a number The pattern follows three letters s, v and d. If a letter is by its own, the number assigned to the letter is assumed to be one. Else it takes the value preceeding it. I then need to add the numbers together. Example ... (5 Replies)
Discussion started by: kristinu
5 Replies

5. Shell Programming and Scripting

Creating single pattern for matching multiple files.

Hi friends, I have a some files in a directory. for example 856-abc 856-def 851-abc 945-def 956-abc 852-abc i want to display only those files whose name starts with 856* 945* and 851* using a single pattern. i.e 856-abc 856-def 851-abc 945-def the rest of the two files... (2 Replies)
Discussion started by: Little
2 Replies

6. UNIX for Dummies Questions & Answers

Find pattern suffix matching pattern

Hi, I am trying to get a result out of this but fails please help. Have two files /tmp/1 & /tmp/hosts. /tmp/1 IP=123.456.789.01 WAS_HOSTNAME=abcdefgh.was.tb.dsdc /tmp/hosts 123.456.789.01 I want this result in /tmp/hosts if hostname is already there dont want duplicate entry. ... (5 Replies)
Discussion started by: rajeshwebspere
5 Replies

7. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

8. Shell Programming and Scripting

PHP - Regex for matching string containing pattern but without pattern itself

The sample file: dept1: user1,user2,user3 dept2: user4,user5,user6 dept3: user7,user8,user9 I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Discussion started by: urello
8 Replies

9. UNIX for Dummies Questions & Answers

Grep -v lines starting with pattern 1 and not matching pattern 2

Hi all! Thanks for taking the time to view this! I want to grep out all lines of a file that starts with pattern 1 but also does not match with the second pattern. Example: Drink a soda Eat a banana Eat multiple bananas Drink an apple juice Eat an apple Eat multiple apples I... (8 Replies)
Discussion started by: demmel
8 Replies

10. Shell Programming and Scripting

Expect pattern matching in the command output

This is the command output need to be matched: Telnet console listening to port 42365. (the port number changes every time) Code to test it: ======================================= #!/tools/AGRtools/bin/expect exp_internal 1 set timeout 10 spawn bash set bashId $spawn_id ... (4 Replies)
Discussion started by: marsala
4 Replies
DWARF_GET_CIE_INFO(3)					   BSD Library Functions Manual 				     DWARF_GET_CIE_INFO(3)

NAME
dwarf_get_cie_info -- retrieve information associated with a CIE descriptor LIBRARY
DWARF Access Library (libdwarf, -ldwarf) SYNOPSIS
#include <libdwarf.h> int dwarf_get_cie_info(Dwarf_Cie cie, Dwarf_Unsigned *cie_byte_len, Dwarf_Small *version, char **augmentation, Dwarf_Unsigned *caf, Dwarf_Unsigned *daf, Dwarf_Half *ra, Dwarf_Ptr *init_inst, Dwarf_Unsigned *inst_len, Dwarf_Error *err); DESCRIPTION
Function dwarf_get_cie_info() retrieves the information associated with a given CIE descriptor. Argument cie should reference a valid DWARF CIE descriptor, such as would be returned by function dwarf_get_cie_of_fde(3). Argument cie_byte_len should point to a location that will hold the length in bytes of the CIE descriptor itself. Argument version should point to a location that will hold the version number of the CIE descriptor. Arugment augmentation should point to a location that will be set to a pointer to a NUL-terminated string containing augmentation data encoded as UTF-8. Argument caf should point to a location that will hold the code alignment factor recorded in the CIE descriptor. Arugment daf should point to a location that will hold the data alignment factor recorded in the CIE descriptor. Argument ra should point to a location that will hold the return address recorded in the CIE descriptor. Argument init_inst should point to a location that will be set to a pointer to an array of bytes containing the initial instructions associ- ated with the CIE descriptor. Argument inst_len should point to a location that will hold the length in bytes of the initial instructions returned in argument init_inst. If argument err is not NULL, it will be used to store error information in case of an error. RETURN VALUES
Function dwarf_get_cie_info() returns DW_DLV_OK when it succeeds. In case of an error, it returns DW_DLV_ERROR and sets the argument err. ERRORS
Function dwarf_get_cie_info() can fail with: [DW_DLE_ARGUMENT] One of the arguments cie, cie_byte_len, version, augmentation, caf, daf, ra, init_inst or inst_len was NULL. SEE ALSO
dwarf(3), dwarf_get_cie_index(3), dwarf_get_cie_of_fde(3), dwarf_get_fde_at_pc(3), dwarf_get_fde_info_for_all_regs(3), dwarf_get_fde_info_for_all_regs3(3), dwarf_get_fde_info_for_cfa_reg3(3), dwarf_get_fde_info_for_reg(3), dwarf_get_fde_info_for_reg3(3), dwarf_get_fde_instr_bytes(3), dwarf_get_fde_list(3), dwarf_get_fde_list_eh(3), dwarf_get_fde_n(3), dwarf_get_fde_range(3) BSD
May 29, 2011 BSD
All times are GMT -4. The time now is 04:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy