Operating System - HP-UX
1752510 Members
4537 Online
108788 Solutions
New Discussion юеВ

Re: combining some row of file 1 and file2 to third file

 
DeafFrog
Valued Contributor

combining some row of file 1 and file2 to third file

Hi gurus ,

 

the first file , file 1 contains entries like :

 

\Hosts\HPUX\FINDBDR\10 information:

object

  objectid .............................: 0A880710804301604165A50200C0000000005D00

  objectname ...........................: \Hosts\HPUX\FINDBDR\10

  objecttype ...........................: presentedunit

  objectwwn ............................:

  objecthexuid .........................: 6001-4380-02a5-6541-0000-c000-005d-0000

  virtualdiskname ......................: \Virtual Disks\HPUX\COREDBDR10\ACTIVE

  virtualdiskid ........................: 0A200710804301604165A50200C0000000005400

  hostname .............................: \Hosts\HPUX\FINDBDR

  hostid ...............................: 02800710804301604165A5020090000000000500

  lunnumber ............................: 11

 

 

\Hosts\HPUX\FINDBDR\12 information:

object

  objectid .............................: 2B880710804301604165A50200C0000000005E00

  objectname ...........................: \Hosts\HPUX\FINDBDR\12

  objecttype ...........................: presentedunit

  objectwwn ............................:

  objecthexuid .........................: 6001-4380-02a5-6541-0000-c000-005e-0000

  virtualdiskname ......................: \Virtual Disks\HPUX\COREDBDR11\ACTIVE

  virtualdiskid ........................: 27200710804301604165A50200C0000000005700

  hostname .............................: \Hosts\HPUX\FINDBDR

  hostid ...............................: 02800710804301604165A5020090000000000500

  lunnumber ............................: 12

 

.....

 

The second file file2 , conatins entries like

:

\Virtual Disks\HPUX\COREDBDR10\ACTIVE information:

object

  objectid .............................: 0A200710804301604165A50200C0000000005400

  objectname ...........................: \Virtual Disks\HPUX\COREDBDR10\ACTIVE

  objecttype ...........................: virtualdisk

  objectwwn ............................:

  objecthexuid .........................: 6001-4380-02a5-6541-0000-c000-0054-0000

  partitionname ........................: ACTIVE

  uid ..................................: 0A200710804301604165A50200C0000000005400

  parentstoragecellinfo

    storagecellname ....................: BDDREVA8100

    storagecellid ......................: 0800071080430160B764A5020070000000000200

    storagecellwwn .....................: 5000-1FE1-500F-4F70

  objectparentuid ......................: 00000710804301604165A50200C0000000005300

  objectparenthexuid ...................: 6001-4380-02a5-6541-0000-c000-0053-0000

  objectparentid .......................: 00000710804301604165A50200C0000000005300

  comments .............................:

  creationdatetime .....................: 17-Jan-2011 15:35:27

  timestampmodify ......................: 219118642

  previousclonesourcevdiskid ...........: 0000000000000000000000000000000000000000

  previousclonesourcevdiskhexuid .......: 0000-0000-0000-0000-0000-0000-0000-0000

  familyname ...........................: COREDBDR10

  wwlunid ..............................: 6001-4380-02a5-6541-0000-c000-0054-0000

  dirtyblockcount ......................: 0

  onlinecontroller

    controllername .....................: Controller A

    controllerid .......................: 0000070880430150B764A5020000000000000000

  operationalstate .....................: good

  operationalstatedetail ...............: operating_normally

  allocatedcapacity ....................: 150

...

 

I am trying to create a third file , file3 from combining some of entires above  like

 

 

Objectname(from file1): virtualdiskname(common in file 1 and file 2):wwlunid(file2):creationdatetime(file2):operationalstate(file2):allocatedcapacity(file2)

 

I tried a combination of grep and awk , but that didnтАЩt worked out.

Appricate your help

 

 

 

 

 

 

FrogIsDeaf
3 REPLIES 3
Dennis Handly
Acclaimed Contributor

Re: combining some rows of file1 and file2 to third file

>I am trying to create a third file, file3 from combining some of entries

 

Basically in awk you read in file1 and save the entries you want to keep in arrays.

Then you read in file2 and match them up and print them.

DeafFrog
Valued Contributor

Re: combining some row of file 1 and file2 to third file

thank you Dennis , I will try to form the correct syntax .
FrogIsDeaf
Dennis Handly
Acclaimed Contributor

Re: combining some row of file 1 and file2 to third file

Here is an example of how to read one file in awk and put into an array, then read the rest of the files and check the array:

http://h30499.www3.hp.com/t5/Languages-and-Scripting/sh-script-find-string-in-two-different-files-and-compare/m-p/6331275#M46680