- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- How can i get specifically some lines between a si...
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
Discussions
Discussions
Discussions
Forums
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
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
тАО04-24-2011 01:11 PM
тАО04-24-2011 01:11 PM
How can i get specifically some lines between a sign ?
i have this output file:
scheduled Jobs:
Level type Pri
==== (this is a note: first "=")
..xxxx
..xxxx
..xxxx
..xxxx
..xxxx
..xxxx
..xxxx
..xxxx
==== (this is a note: second "=")
Ended Jobs
Level type Pri
===== (this is a note: third "=")
....
...
..
...
....
===== (this is a note: fourth "=")
i want to get only the lines between the first "=" and the second "=", it means, only the scheduled Jobs --> lines: ..xxxx
How can i get them? can i do it with awk? please your support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-24-2011 02:09 PM
тАО04-24-2011 02:09 PM
Re: How can i get specifically some lines between a sign ?
As you stated your requirement and the pattern of the data:
perl -ne 'if (?^===?...?^===?) {print unless /^===/}' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2011 09:05 AM
тАО04-25-2011 09:05 AM
Re: How can i get specifically some lines between a sign ?
## cat /tmp/doit
#
awk '
BEGIN {c=0}
{
while (getline) {
if ( match($0 , "===") ) {
c=c+1
if (c>=2) { exit }
continue
}
if (c==0) {
continue
}
if (c==1) {
print $0
continue
}
}
}
END { }
'
Here's a run of it:
## cat /tmp/in | /tmp/doit
..xxxx1
..xxxx2
..xxxx3
..xxxx4
..xxxx5
..xxxx6
..xxxx7
..xxxxE
bv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2011 09:54 AM
тАО04-25-2011 09:54 AM
Re: How can i get specifically some lines between a sign ?
in my opinion it is better to keep the awk standard parsing:
awk '/^====/ {mark++}
mark>1 {exit}
mark'
mfg Peter
PS: untested
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2011 10:41 AM
тАО04-25-2011 10:41 AM
Re: How can i get specifically some lines between a sign ?
I've found it easier to use 'awk' in the complex way rather than trying to grok the eccentricities of it's simpler syntax.
Of course, then it just becomes another programming language.
I got used to using it before 'perl' was around.
BTW, your script prints the first "====" line , but I don't know how to fix it :>)
bv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-25-2011 11:33 AM
тАО04-25-2011 11:33 AM
Re: How can i get specifically some lines between a sign ?
I too started that way but I learn as I go along.
>but I don't know how to fix it :>)
A "next" will cause it to go to the next cycle, think of it as a super "continue":
awk '
/^====/ {
if (++mark > 1) exit
next
}
mark { print $0 }' input-file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-26-2011 12:23 AM
тАО04-26-2011 12:23 AM
Re: How can i get specifically some lines between a sign ?
other solution without the 'xxxx'-line:
awk 'mark
/^====/ {mark++}
mark>1 {exit}'