- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: perl scripting
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
05-02-2003 11:40 AM
05-02-2003 11:40 AM
perl scripting
Could some pls. explain what this piece of code does?
perl -ne '{$n=5 if /^matched/;$n--,print $_ if $n;$n=0 if eof}' logfile
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2003 11:47 AM
05-02-2003 11:47 AM
Re: perl scripting
I think.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2003 12:07 PM
05-02-2003 12:07 PM
Re: perl scripting
if "match" found at start of line then
n-- i.e n=4
print line
then I am confuse. may be running until end of logfile
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2003 12:13 PM
05-02-2003 12:13 PM
Re: perl scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2003 12:17 PM
05-02-2003 12:17 PM
Re: perl scripting
Suppose you have a log file that you always need a set of 5 lines where the first line always begins with 'matched' (or anything you put in the /'s), but the other lines vary. This would be a good way to only grab those sets of lines that you need without having to search through the rest of the logfile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2003 12:32 PM
05-02-2003 12:32 PM
Re: perl scripting
logfile
=======
1 hello there
2 matched me
3 noway I am doing this
4 plese let me go
5 jump
6 let me go
7 dont do it
8 matched me number 2
9 hello again
10 matched me number 3
11 noway U are buying this
12 matched
13 no-way I am doing this
14 please let me go
15 jump
16 let me go
17 dont do it
18 matched
19 matched
The output would be lines
2,3,4,5,6,8,9,10,11,12,13,14,15,16,18,19
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2003 01:59 AM
05-03-2003 01:59 AM
Re: perl scripting
# perl -ne '/^matched/ and$n=5;--$n and print' logfile
does exactly the same. S.K.'s explanation is perfect.
Enjoy, have FUN! H.Merijn