HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grep last time "rndc reload" messages plus the nex...
Operating System - HP-UX
1833784
Members
2497
Online
110063
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
07-03-2004 06:44 AM
07-03-2004 06:44 AM
Hi,
The /var/adm/syslog/syslog.log captures several times "rndc reload", but I just want to see the last time rndc reload messages plus the next 20 lines after it.
Do you know how can I do that? with grep command it doesn't perform what I want.
Please give me a tips.
//john
The /var/adm/syslog/syslog.log captures several times "rndc reload", but I just want to see the last time rndc reload messages plus the next 20 lines after it.
Do you know how can I do that? with grep command it doesn't perform what I want.
Please give me a tips.
//john
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2004 06:58 AM
07-03-2004 06:58 AM
Solution
This is a simple shell script which will do the task. Anyway you may get a onliner from one of our perl experts.
==========================
a=0
cp /var/adm/syslog/syslog.log /tmp/syslog.log
cat /tmp/syslog.log|while read line
do
a=`echo "$a + 1" |bc`
echo $a $line >>/tmp/output$$
done
LASTLINE=`cat /tmp/output$$ |grep 'rndc reload' |tail -1|cut -f 1 -d " "`
TOTALLEN=`wc -l /tmp/syslog.log`
FORTAIL=`echo "$TOTALLINE - $LASTLINE " |bc`
cat /tmp/syslog.log |tail -$FORTAIL|head -20
==========================
Regds,
Kaps
==========================
a=0
cp /var/adm/syslog/syslog.log /tmp/syslog.log
cat /tmp/syslog.log|while read line
do
a=`echo "$a + 1" |bc`
echo $a $line >>/tmp/output$$
done
LASTLINE=`cat /tmp/output$$ |grep 'rndc reload' |tail -1|cut -f 1 -d " "`
TOTALLEN=`wc -l /tmp/syslog.log`
FORTAIL=`echo "$TOTALLINE - $LASTLINE " |bc`
cat /tmp/syslog.log |tail -$FORTAIL|head -20
==========================
Regds,
Kaps
Nothing is impossible
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2004 08:29 AM
07-03-2004 08:29 AM
Re: grep last time "rndc reload" messages plus the next 50 lines
Not a one liner, but an easy to read perl solution below:
- loop through the file
- if you see the target string, forget the array with lines remembered earlier and setup a count of lines to remember.
- if there is a count of lines left to remember, then push lines ($_) into an array
- when no more data (end while) print each of the latests remembered lines from the array.
----------------- x.pl ---------------
while (<>) {
if (/rndc reload/) {
undef @lines;
$more = 50;
}
if ($more) {
push (@lines, $_);
$more--;
}
}
foreach $_ (@lines) {print};
---------------------------------------
perl x.pl /var/adm/syslog/syslog.log
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP