Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Need Help on sed

 
Ajin_1
Valued Contributor

Need Help on sed

Hi Experts

 

Thanks in Advance.

 

The below command Prints as below

 

# ll /dev/rdsk | awk '{print $10}' | sed s/dsk/rdsk/g

c0t0d0
c2t0d0
c2t1d0
c7t0d1
c7t0d2
c7t0d3
c7t0d4
c7t0d5
c8t0d1
c8t0d2
c8t0d3
c8t0d4
c8t0d5

 

My requrement is it shoud print /dev/rdsk/c2t767 like all the files under /dev/dsk dir

 

And print the PV id for this device files using the below script

 

xd -j8200 -N16 -tx /dev/rdsk/c17t1d6 /dev/rdsk/c13t1d6 /dev/rdsk/c19t1d6 /dev/rdsk/c15t1d6

 

Please help

Thanks & Regards
Ajin.S
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: Need help getting PV ID on files in /dev/rdsk/

>My requirement is it should print /dev/rdsk/c2t767 like all the files under /dev/dsk dir

 

Then use a better command:

ls /dev/rdsk/*

 

>And print the PV id for this device files using the below script

 

for disk in $(ls /dev/rdsk/*); do

   echo "Doing $disk: ============="

   xd -j8200 -N16 -tx $disk

done

Ajin_1
Valued Contributor

Re: Need help getting PV ID on files in /dev/rdsk/

Hi Dennis

 

Thank you verymuch for quick reply.

In th below output its possible to filter specific disk details based on date which it created.

 

And also in our setup we are using One PV having 3 alternate liks having same PVID  ,

In this senario Shall I get the device files using same PVID

Your help is welcome.

 

# cd /dev/rdsk
# ll
total 0
crw-r-----   1 bin        sys        188 0x000000 Jun 25  2012 c0t0d0
crw-r-----   1 bin        sys        188 0x020000 Nov 13  2012 c2t0d0
crw-r-----   1 bin        sys        188 0x021000 Nov 13  2012 c2t1d0
crw-r-----   1 bin        sys        188 0x070100 Nov 13  2012 c7t0d1
crw-r-----   1 bin        sys        188 0x070200 Nov  1  2012 c7t0d2
crw-r-----   1 bin        sys        188 0x070300 Nov  1  2012 c7t0d3
crw-r-----   1 bin        sys        188 0x070400 Nov  1  2012 c7t0d4
crw-r-----   1 bin        sys        188 0x070500 Nov  1  2012 c7t0d5
crw-r-----   1 bin        sys        188 0x080100 Nov  1  2012 c8t0d1
crw-r-----   1 bin        sys        188 0x080200 Nov  1  2012 c8t0d2
crw-r-----   1 bin        sys        188 0x080300 Nov  1  2012 c8t0d3
crw-r-----   1 bin        sys        188 0x080400 Nov  1  2012 c8t0d4
crw-r-----   1 bin        sys        188 0x080500 Nov  1  2012 c8t0d5

Thanks & Regards
Ajin.S
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Dennis Handly
Acclaimed Contributor

Re: Need help getting PV ID on files in /dev/rdsk/

>it's possible to filter specific disk details based on date which it created.

 

Yes, you can get that with:

ll /dev/rdsk/*

 

Or use: find /dev/rdsk -mtime -N

Or use: find /dev/rdsk -newer reference-file

Ajin_1
Valued Contributor

Re: Need help getting PV ID on files in /dev/rdsk/

Hi Dennis

 

 

Thank you

 

The below is the output

 

From this output using script its possible to remove the enrties which is having the PVID 0

 

# ./pvid.sh
Doing /dev/rdsk/c0t0d0: =============
xd: Error reading file /dev/rdsk/c0t0d0
Doing /dev/rdsk/c2t0d0: =============
0000000         e08388d5        4fe7ccfe        e08388d5        4fe7ccfe
0000010
Doing /dev/rdsk/c2t1d0: =============
0000000         e08388d5        507fad07        e08388d5        4fe7ccfe
0000010
Doing /dev/rdsk/c7t0d1: =============
0000000         e08388d5        50a20b14        e08388d6        50a20db2
0000010
Doing /dev/rdsk/c7t0d2: =============
0000000                0               0               0               0
0000010
Doing /dev/rdsk/c7t0d3: =============
0000000                0               0               0               0
0000010
Doing /dev/rdsk/c7t0d4: =============
0000000                0               0               0               0
0000010
Doing /dev/rdsk/c7t0d5: =============
0000000                0               0               0               0
0000010
Doing /dev/rdsk/c8t0d1: =============
0000000         e08388d5        50a20b14        e08388d6        50a20db2
0000010
Doing /dev/rdsk/c8t0d2: =============
0000000                0               0               0               0
0000010
Doing /dev/rdsk/c8t0d3: =============
0000000                0               0               0               0
0000010
Doing /dev/rdsk/c8t0d4: =============
0000000                0               0               0               0
0000010
Doing /dev/rdsk/c8t0d5: =============
0000000                0               0               0               0
0000010

Thanks & Regards
Ajin.S
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Highlighted
Dennis Handly
Acclaimed Contributor

Re: Need help getting PV ID on files in /dev/rdsk/

>it's possible to remove the enrties which is having the PVID 0?

 

Just pipe to grep:

grep -v -e "^00000010" -e "       0               0               0               0"

(Assuming I counted the spaces correctly.)