- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- awk question: Change /dev/dsk/c101t2d4 -> c101t2d...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 03:39 AM
08-22-2005 03:39 AM
line:
Device Physical Name : /dev/rdsk/c101t5d3
Device Serial ID : Ch2 CONT
Vendor ID : DGC
Product ID : CX700WDR5
Product Revision : HP03
Capacity (in KB) : 8838720
Clariion ID : APM00052802175
Device Clariion Name : 0117
Device State : ASSIGNED
VxVM DMP Device Type : N/A
Device Physical Name : /dev/rdsk/c101t5d4
Device Serial ID : Ch2 CONT
Vendor ID : DGC
Product ID : CX700WDR5
Product Revision : HP03
Capacity (in KB) : 70709760
Clariion ID : APM00052802175
Device Clariion Name : 0116
Device State : ASSIGNED
VxVM DMP Device Type : N/A
b. Do this:
awk '
/Device Phys/ {CTD=$5; next}
/Product ID/ {PROD=$4; next}
/Capacity/ {CAP=$5; next}
/Clariion ID/ {ARRAY=$4; next}
/Device Clar/ {LUN=$5; next}
/VxVM/ {print CTD, PROD, CAP/1000000, ARRAY, LUN}' \
syminq-v-clar
/dev/rdsk/c101t5d3 CX700WDR5 8.83872 APM00052802175 0117
/dev/rdsk/c101t5d4 CX700WDR5 70.7098 APM00052802175 0116
c. But I don't want "/dev/rdsk/c101t5d3".
I want "c101t5d3".
d. So, how do I modify the above little awk program to strip out the "/dev/dsk/".
I have been messing around with "sub" and "gsub", with no good result.
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 03:51 AM
08-22-2005 03:51 AM
Re: awk question: Change /dev/dsk/c101t2d4 -> c101t2d4
I assume your final out put is now
dev/rdsk/c101t5d3 CX700WDR5 8.83872 APM00052802175 0117
/dev/rdsk/c101t5d4 CX700WDR5 70.7098 APM00052802175 0116
Now to eliminate the /dev/rdsk you can input this output to
awk '{print $1 }'|cut -f 4 -d "/"
Regards,
Syam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 03:54 AM
08-22-2005 03:54 AM
Re: awk question: Change /dev/dsk/c101t2d4 -> c101t2d4
My limited brain says to just re-awk the first element in each line with something like:
awk -F "/" {'print $4'}
I'm sure someone with more awk knowledge can find a better way to streamline it into your existing code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 03:59 AM
08-22-2005 03:59 AM
Re: awk question: Change /dev/dsk/c101t2d4 -> c101t2d4
sub(r,s,t)
Substitute s for the first match of the RE r in the string t. If argument t is not supplied, $0 is used. You can substitute a null string to remove matching RE's.
RE => regular expression
Sub returns 1 if okay and 0 otherwise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 04:00 AM
08-22-2005 04:00 AM
Re: awk question: Change /dev/dsk/c101t2d4 -> c101t2d4
... | sed -e "1,1s+/dev/dsk/++
I think it will eliminate the string.
UNIX because I majored in cryptology...
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 04:00 AM
08-22-2005 04:00 AM
Re: awk question: Change /dev/dsk/c101t2d4 -> c101t2d4
change
/Device Phys/ {CTD=$5; next}
to
/Device Phys/ {split($5,a,"/"); CTD=a[3];next;}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 04:14 AM
08-22-2005 04:14 AM
Re: awk question: Change /dev/dsk/c101t2d4 -> c101t2d4
=============================================
awk '
/Device Phys/ {CTD=z[split($5,z,"/")]; next}
/Product ID/ {PROD=$4; next}
/Capacity/ {CAP=$5; next}
/Clariion ID/ {ARRAY=$4; next}
/Device Clar/ {LUN=$5; next}
/VxVM/ {print CTD, PROD, CAP/1000000, ARRAY, LUN}' \
syminq-v-clar
=============================================
regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 04:18 AM
08-22-2005 04:18 AM
Re: awk question: Change /dev/dsk/c101t2d4 -> c101t2d4
sandman, nice syntax to get the last field. i'll have to write that one done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 04:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 05:34 AM
08-22-2005 05:34 AM
Re: awk question: Change /dev/dsk/c101t2d4 -> c101t2d4
you can pipe the output into :
sed -e "s/\/dev\/rdsk\///"
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 06:41 AM
08-22-2005 06:41 AM
Re: awk question: Change /dev/dsk/c101t2d4 -> c101t2d4
There is always several solutions, for this specific problem I would use the gsub function in awk as recommended by Clay. But, another method that I have often used with awk scripts is to pre-process the file before piping it to awk. In your case, you can translate the "/" to " " (using the tr command) and then "print $NF" in awk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2005 01:40 PM
08-22-2005 01:40 PM
Re: awk question: Change /dev/dsk/c101t2d4 -> c101t2d4
DEVFILE=/dev/rdsk/c101t5d3
DISK=$(basename $DEVFILE)
Or better yet, let the shell do the stripping:
DISK=${DEVFILE##*/}
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2005 01:36 AM
08-23-2005 01:36 AM