- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk or something else
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
09-18-2006 09:07 PM
09-18-2006 09:07 PM
omnidb output:
#omnidb -session -user root -last 3 -type backup -detail
SessionID : 2006/09/19-3
Backup Specification: EP2
Session type : Backup (full)
Started : Tue Sep 19 05:00:00 2006
Finished : Tue Sep 19 09:21:47 2006
Status : Completed
Number of warnings : 0
Number of errors : 0
User : root
Group : sys
Host : lev
How can I do that using awk or some different way?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 09:11 PM
09-18-2006 09:11 PM
Re: awk or something else
Using the output of your omnidb command:
head -2 | awk -F':' '{print $2}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 09:21 PM
09-18-2006 09:21 PM
Re: awk or something else
# omnidb -session -user root -last 3 -type backup -detail | perl -ne'm/^(SessionID|Backup Specification)\b/&&s/.*?:\s*//&&print'
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 09:43 PM
09-18-2006 09:43 PM
Re: awk or something else
I need to get two fields Session ID an Backup Specification simultaneosly, not only Session ID.
Or if it is not possible, how to get Session ID that belongs to Backup Specification EP2?
The output of omnidb could be different than that I've posted, depending on number of sessions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 09:48 PM
09-18-2006 09:48 PM
Re: awk or something else
you need pure awk only:
omnidb -session -user root -last 3 -type backup -detail |
awk '/^SessionID/ {print $NF}
/^ Backup Specification/ {print $NF;exit}'
or in Peter G.'s solution:
... | awk -F: 'NR>3 {print $2}'
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 09:49 PM
09-18-2006 09:49 PM
Re: awk or something else
must use '<' and not '>':
##
or in Peter G.'s solution:
... | awk -F: 'NR<3 {print $2}'
##
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 09:51 PM
09-18-2006 09:51 PM
Re: awk or something else
doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:09 PM
09-18-2006 10:09 PM
Re: awk or something else
The full output is:
root@lev /opt/omni>omnidb -session -user root -last 3 -type backup -detail
SessionID : 2006/09/16-2
Backup Specification: EP2
Session type : Backup (full)
Started : Sat Sep 16 05:00:01 2006
Finished : Sat Sep 16 09:22:00 2006
Status : Completed
Number of warnings : 0
Number of errors : 0
User : root
Group : sys
Host : lev
SessionID : 2006/09/16-16
Backup Specification: DMProd
Session type : Backup (full)
Started : Sat Sep 16 23:45:00 2006
Finished : Sun Sep 17 02:23:52 2006
Status : Completed
Number of warnings : 1
Number of errors : 0
User : root
Group : sys
Host : lev
SessionID : 2006/09/17-1
Backup Specification: ServiceDesk
Session type : Backup (full)
Started : Sun Sep 17 03:00:01 2006
Finished : Sun Sep 17 04:40:24 2006
Status : Completed
Number of warnings : 0
Number of errors : 0
User : root
Group : sys
Host : lev
SessionID : 2006/09/17-2
Backup Specification: EP2
Session type : Backup (full)
Started : Sun Sep 17 05:00:00 2006
Finished : Sun Sep 17 09:21:42 2006
Status : Completed
Number of warnings : 0
Number of errors : 0
User : root
Group : sys
Host : lev
SessionID : 2006/09/17-14
Backup Specification: DP Database
Session type : Backup (full)
Started : Sun Sep 17 20:00:01 2006
Finished : Sun Sep 17 20:30:17 2006
Status : Completed
Number of warnings : 0
Number of errors : 0
User : root
Group : sys
Host : lev
How to get the following?:
SessionID : 2006/09/16-2
Backup Specification: EP2
SessionID : 2006/09/17-2
Backup Specification: EP2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:15 PM
09-18-2006 10:15 PM
Re: awk or something else
"The output of omnidb could be different than that I've posted, depending on number of sessions." - Can you please post a file with all the formats you want to analyse ?
"I need to get two fields Session ID an Backup Specification simultaneosly, not only Session ID. Or if it is not possible, how to get Session ID that belongs to Backup Specification EP2?" - Can you please give an example of what you want as an output, given the input as requested above.
For example my solution assumed no blank leading line in input and that you wanted the ouput on two lines.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:21 PM
09-18-2006 10:21 PM
Re: awk or something else
omnidb -session -user root -last 3 -type backup -detail | grep -e "^Backup Specification" -e "^SessionID"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:21 PM
09-18-2006 10:21 PM
Re: awk or something else
Does it give an error message?
Taking your last paste, and using that as input:
lt09:/home/merijn 102 > perl -ne'm/^(SessionID|Backup Specification)\b/&&s/.*?:\s*//&&print' omni.out
2006/09/16-2
EP2
2006/09/16-16
DMProd
2006/09/17-1
ServiceDesk
2006/09/17-2
EP2
2006/09/17-14
DP Database
looks perfectly fine to me.
What is the perl you use?
# perl -v
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:32 PM
09-18-2006 10:32 PM
Re: awk or something else
root@lev /Ignite_Bckp>perl -v
This is perl, v5.8.0 built for IA64.ARCHREV_0-thread-multi
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2002, Larry Wall
Binary build 803 provided by ActiveState Corp. http://www.ActiveState.com
Built 16:06:31 Nov 24 2002
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
I dont understand how to use your construction.. Could you post the whole command?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:40 PM
09-18-2006 10:40 PM
Re: awk or something else
to get the output for multiple sessions, just leave the 'exit'; to get one-liner info additionally, use:
omnidb -session -user root -last 3 -type backup -detail |
awk '/^SessionID/ {id=$NF}
/^ Backup Specification/ {print id,$NF}'
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:45 PM
09-18-2006 10:45 PM
Re: awk or something else
I do not get any output using your last command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:46 PM
09-18-2006 10:46 PM
Re: awk or something else
root@lev /opt/omni>omnidb -session -user root -last 3 -type backup -detail >omni.out
root@lev /opt/omni>perl -ne'm/^(SessionID|Backup Specification)\b/&&s/.*?:\s*//&&print' omni.out
or, without the file
root@lev /opt/omni>omnidb -session -user root -last 3 -type backup -detail | perl -ne'm/^(SessionID|Backup Specification)\b/&&s/.*?:\s*//&&print' omni.out
I've just tried perl5.8.0 on a HP-UX 10.20 box, and that also runs fine:
d3:/u/usr/merijn 105 > perl5.8.0 -ne'm/^(SessionID|Backup Specification)\b/&&s/.*?:\s*//&&print' omni.out
2006/09/16-2
EP2
2006/09/16-16
DMProd
2006/09/17-1
ServiceDesk
2006/09/17-2
EP2
2006/09/17-14
DP Database
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:51 PM
09-18-2006 10:51 PM
Re: awk or something else
This works for me (without blank space between ^ and Backup):
omnidb -session -user root -last 3 -type backup -detail |
awk '/^SessionID/ {id=$NF}
/^Backup Specification/ {print id,$NF}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 10:54 PM
09-18-2006 10:54 PM
Re: awk or something else
hmm .. dont know what's the problem
I get only SessionID fields:
2006/09/16-2
2006/09/16-16
2006/09/17-1
2006/09/17-2
2006/09/17-14
2006/09/17-17
2006/09/18-2
2006/09/18-19
2006/09/19-1
2006/09/19-3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 11:21 PM
09-18-2006 11:21 PM
Re: awk or something else
Can you *attach* the output, instead of paste it?
For the next time you paste data that is to be parsed, please tick the '[ ] Retain format (spacing)' checkbox under the input text box, so the spaces are preserved.
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2006 11:26 PM
09-18-2006 11:26 PM
Re: awk or something else
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 12:14 AM
09-19-2006 12:14 AM
Re: awk or something else
If you take off the ^ symbol from any of the previous examples you will see it working.
Anyway, it's better if you adjust the expression to the output to avoid false detections.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 12:21 AM
09-19-2006 12:21 AM
Re: awk or something else
This will work:
omnidb -session -user root -last 3 -type backup -detail |
awk '/^SessionID/ {id=$NF}
/Backup Specification:/ {print id,$NF}'
But it will be better if you use this:
omnidb -session -user root -last 3 -type backup -detail |
awk '/^SessionID/ {id=$NF}
/^ Backup Specification:/ {print id,$NF}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 12:23 AM
09-19-2006 12:23 AM
Re: awk or something else
# perl -ne'm/^\s*(SessionID|Backup Specification)\b/&&s/.*?:\s*//&&print' omni.out
Should work. An alternate output could be:
perl -ne'm/^SessionID\s*:\s*(.*)/and$sid=$1;if(s/^\s*Backup Specification\s*:\s*//){s/$/ : $sid/;print}' omni.out
EP2 : 2006/09/16-2
DMProd : 2006/09/16-16
ServiceDesk : 2006/09/17-1
EP2 : 2006/09/17-2
DP Database : 2006/09/17-14
Or reverse:
# perl -nle'm/^SessionID\s*:\s*(.*)/and$sid=$1;s/^\s*Backup Specification\s*:\s*//&&print"$sid\t$_"' omni.out
2006/09/16-2 EP2
2006/09/16-16 DMProd
2006/09/17-1 ServiceDesk
2006/09/17-2 EP2
2006/09/17-14 DP Database
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 02:55 AM
09-19-2006 02:55 AM
Re: awk or something else
ok - awk solution, which deals with multiple spaces:
omnidb -session -user root -last 3 -type backup -detail |
awk '$1 == "SessionID" {id=$NF}
/Backup Specification/ {print id,$NF}'
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2006 03:23 AM
09-19-2006 03:23 AM
Re: awk or something else
# awk '{if($0~"EP2") print l"\n"$0; l=$0}' infile
~cheers