- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh / awk to parse "syminq" output ?
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
12-03-2004 02:57 AM
12-03-2004 02:57 AM
/dev/rdsk/c13t0d0........EMC..SYMMETRIX..5568..84000000.......7680
/dev/rdsk/c13t3d1..M(4)..EMC..SYMMETRIX..5568..840C1000...35354880
/dev/rdsk/c13t3d2..M(4)..EMC..SYMMETRIX..5568..840C5000...35354880
/dev/rdsk/c13t3d3..M(4)..EMC..SYMMETRIX..5568..840C9000...35354880
/dev/rdsk/c13t3d4..M(4)..EMC..SYMMETRIX..5568..840CD000...35354880
/dev/rdsk/c13t3d5..M(4)..EMC..SYMMETRIX..5568..840D1000...35354880
/dev/rdsk/c13t3d6..M(4)..EMC..SYMMETRIX..5568..840D5000...35354880
/dev/rdsk/c13t7d0........EMC..SYMMETRIX..5568..8437A000....8838720
/dev/rdsk/c15t0d0........EMC..SYMMETRIX..5568..84000000.......7680
the 2nd field isn't always filled in. I want to parse the line using ksh or awk (NO PERL) so that the "EMC" field is always the 3rd field; even when the "M(X)" isn't present.
Can anyone tell me how to do that in ksh or awk, please?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 03:01 AM
12-03-2004 03:01 AM
Re: ksh / awk to parse "syminq" output ?
syminq output | awk -F ".." '{if($3==EMC)print}'
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 03:07 AM
12-03-2004 03:07 AM
Re: ksh / awk to parse "syminq" output ?
That ius, what data are you looking to get out of the syminq?
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 03:51 AM
12-03-2004 03:51 AM
Re: ksh / awk to parse "syminq" output ?
syminq output | sed -e 's/M(4)//' | awk -F ".." 'whatever you want to do'
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 03:51 AM
12-03-2004 03:51 AM
Re: ksh / awk to parse "syminq" output ?
You could use the 'cut' command in a ksh script, or you could use the 'substr' function in awk.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 03:56 AM
12-03-2004 03:56 AM
Re: ksh / awk to parse "syminq" output ?
#!/usr/bin/ksh
# syminq.sh
while read LINE
do
DISK=$(echo $LINE | cut -c1-17)
MVAL=$(echo $LINE | cut -c20-23)
EMC=$(echo $LINE | cut -c26-28)
echo "DISK is $DISK"
echo "MVAL is $MVAL"
echo "EMC is $EMC"
done
(Assuming that your syminq output is in a file named syminq.txt).
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 04:00 AM
12-03-2004 04:00 AM
Re: ksh / awk to parse "syminq" output ?
1. I put "..." in to signify spaces. There are no "..." - there are spaces.
2. You can't use character positions because on differnet servers the field lengths are different. Also, if you have short device file names (c9t1d0) the spacing is (slightly) different than for long names (c22t14d7).
3. What I want to get out of this is a table which shows me that Symm device 0CD on Symm 84 has three device files, c13t3d1, c15t3d1 and c19t3d1, and is of type "M(4)" or "R1" and has size 8.8 GB.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 04:46 AM
12-03-2004 04:46 AM
SolutionFor example here is an awk-
dev=$1; m4=$2; emc=$3; sym=$4; siz=$7
if (m4 == "EMC") {
m4=""; emc=$2; sym=$3; siz=$6
}
Now the awk variables are adjusted depending on if M(4) exists and you can use them in your report.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 04:55 AM
12-03-2004 04:55 AM
Re: ksh / awk to parse "syminq" output ?
Let's assume that you have 10 fields in the records if the 2-nd field is OK and 9 fields if the field is empty.
awk 'NF==10 {print; next}
NF==9 {print $1,"RRR",$2,$3,$4,%5,$6,$7,$8,$9;next}' FILE
Instead of RRR you can use any replacement.
If NF is big, use "for" expression
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 05:43 AM
12-03-2004 05:43 AM
Re: ksh / awk to parse "syminq" output ?
Don't forget to assign points to everyone -
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
http://forums1.itrc.hp.com/service/forums/pageList.do?userId=CA384034&listType=unassigned&forumId=1
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 06:03 AM
12-03-2004 06:03 AM
Re: ksh / awk to parse "syminq" output ?
I don't have the latest version of syminq anymore but maybe there is an option to get it to produce the output with some character that you can use as a field separator?
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2004 06:16 AM
12-03-2004 06:16 AM
Re: ksh / awk to parse "syminq" output ?
Use awk '/EMC/{printf("%s %s %s\n",$1,$(NF-2),$NF)}'.
This would work whether or not the M(4) field exists or not.