|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi all,
The following file lists all disks from a diskbay...and is sorted by disk capacity (first the 146 Go disks, then the 300 Go ones) : objecttype = Disk 146 Go objectname = Disk003 objecttype = Disk 146 Go objectname = Disk005 objecttype = Disk 146 Go objectname = Disk008 objecttype = Disk 300 Go objectname = Disk004 objecttype = Disk 300 Go objectname = Disk016 objecttype = Disk 300 Go objectname = Disk022 objecttype = Disk 300 Go objectname = Disk030 etc... I'd like to write a script that would create 2 files : one containing the 146 Go disks info, and the other with the 300 Go): file1 : objecttype = Disk 146 Go objectname = Disk003 objecttype = Disk 146 Go objectname = Disk005 objecttype = Disk 146 Go objectname = Disk008 file2 : objecttype = Disk 300 Go objectname = Disk004 objecttype = Disk 300 Go objectname = Disk016 objecttype = Disk 300 Go objectname = Disk022 objecttype = Disk 300 Go objectname = Disk030 What would be the simplest way to do this? thanks for your in advance. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
gniagnia wrote:
> Hi all, > > The following file lists all disks from a diskbay...and is sorted by > disk capacity (first the 146 Go disks, then the 300 Go ones) : > > objecttype = Disk 146 Go > objectname = Disk003 > > objecttype = Disk 146 Go > objectname = Disk005 > > objecttype = Disk 146 Go > objectname = Disk008 > > objecttype = Disk 300 Go > objectname = Disk004 > > objecttype = Disk 300 Go > objectname = Disk016 > > objecttype = Disk 300 Go > objectname = Disk022 > > objecttype = Disk 300 Go > objectname = Disk030 > > etc... > > > I'd like to write a script that would create 2 files : one containing > the 146 Go disks info, and the other with the 300 Go): > > file1 : > > objecttype = Disk 146 Go > objectname = Disk003 > > objecttype = Disk 146 Go > objectname = Disk005 > > objecttype = Disk 146 Go > objectname = Disk008 > > > > file2 : > > objecttype = Disk 300 Go > objectname = Disk004 > > objecttype = Disk 300 Go > objectname = Disk016 > > objecttype = Disk 300 Go > objectname = Disk022 > > objecttype = Disk 300 Go > objectname = Disk030 > > > > What would be the simplest way to do this? > > thanks for your in advance. > awk -v RS= '{print > "file"$4}' file Ed. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
> awk -v RS= '{print > "file"$4}' file > > Ed. thx a lot ! But, actually ... my file is a bit more talkative than what i said... Here is a real sample of the file i want to process : \Disk Groups\Disk 146 Go\Disk 002 information: object objectid .............................: 12080710110000201648B9C60000000000000000 objectname ...........................: \Disk Groups\Disk 146 Go \Disk 002 objecttype ...........................: disk objectwwn ............................: objecthexuid .........................: 2000-0011- c6b9-4816-0000-0000-0000-0000 diskname .............................: Disk 002 uid ..................................: 2066.7.16.536870929.3334031382.0.0 operationalstate .....................: good operationalstatedetail ...............: member_ok objectparentuid ......................: 256.7.16.1610942644.1070310.24576.262144 loopalpa .........................: 2b loopposition .....................: 48 loop loopname .........................: loopb portwwid .........................: 2000-0011-C6B9-4816 loopid ...........................: 107 assignedlun ......................: 0 loopstate ........................: good loopalpa .........................: 2b loopposition .....................: 10 formattedcapacity ....................: 286749488 diskdrivetype ........................: online actualusage ..........................: grouped requestedusage .......................: grouped quorumdisk ...........................: no diskgroupname ........................: Disk 146 Go diskgroupid ..........................: 00010710B4080560E65410000060000000000400 diskbaynumber ........................: 10 looppair .............................: looppair1 shelfnumber ..........................: 1 DiskCanCodeLoad ......................: 0 \Disk Groups\Disk 146 Go\Disk 003 information: object objectid .............................: 12080710110000201648B9C60000000000000000 objectname ...........................: \Disk Groups\Disk 146 Go \Disk 002 objecttype ...........................: disk objectwwn ............................: objecthexuid .........................: 2000-0011- c6b9-4816-0000-0000-0000-0000 diskname .............................: Disk 003 uid ..................................: 2066.7.16.536870929.3334031382.0.0 operationalstate .....................: good operationalstatedetail ...............: member_ok objectparentuid ......................: 256.7.16.1610942644.1070310.24576.262144 loopalpa .........................: 2b loopposition .....................: 48 loop loopname .........................: loopb portwwid .........................: 2000-0011-C6B9-4816 loopid ...........................: 107 assignedlun ......................: 0 loopstate ........................: good loopalpa .........................: 2b loopposition .....................: 10 formattedcapacity ....................: 286749488 diskdrivetype ........................: online actualusage ..........................: grouped requestedusage .......................: grouped quorumdisk ...........................: no diskgroupname ........................: Disk 146 Go diskgroupid ..........................: 00010710B4080560E65410000060000000000400 diskbaynumber ........................: 10 looppair .............................: looppair1 shelfnumber ..........................: 1 DiskCanCodeLoad ......................: 0 \Disk Groups\Disk 300 Go\Disk 001 information: object objectid .............................: 12080710110000201648B9C60000000000000000 objectname ...........................: \Disk Groups\Disk 300 Go \Disk 001 objecttype ...........................: disk objectwwn ............................: objecthexuid .........................: 2000-0011- c6b9-4816-0000-0000-0000-0000 diskname .............................: Disk 001 uid ..................................: 2066.7.16.536870929.3334031382.0.0 operationalstate .....................: good operationalstatedetail ...............: member_ok objectparentuid ......................: 256.7.16.1610942644.1070310.24576.262144 loopalpa .........................: 2b loopposition .....................: 48 loop loopname .........................: loopb portwwid .........................: 2000-0011-C6B9-4816 loopid ...........................: 107 assignedlun ......................: 0 loopstate ........................: good loopalpa .........................: 2b loopposition .....................: 10 formattedcapacity ....................: 286749488 diskdrivetype ........................: online actualusage ..........................: grouped requestedusage .......................: grouped quorumdisk ...........................: no diskgroupname ........................: Disk 300 Go diskgroupid ..........................: 00010710B4080560E65410000060000000000400 diskbaynumber ........................: 10 looppair .............................: looppair1 shelfnumber ..........................: 1 DiskCanCodeLoad ......................: 0 i try to fill one file with the 2 first disks details (146 Go), another one with the 300 go disks details....but I am such a noob that i cannot adapt your script with it. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
gniagnia wrote:
>>awk -v RS= '{print > "file"$4}' file >> >> Ed. > > > thx a lot ! > But, actually ... my file is a bit more talkative than what i said... > Here is a real sample of the file i want to process : > > > \Disk Groups\Disk 146 Go\Disk 002 information: <snip> Just use $3 instead of $4. Ed. |
|
![]() |
| Outils de la discussion | |
|
|