- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- broken tail? tail -559 works. tail -561 fails.
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
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
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
03-07-2005 06:26 AM
03-07-2005 06:26 AM
I want to truncate the log.
logfile is 850 lines long.
cat logfile | tail -559 > logfile.tmp
logfile.tmp should be 559 lines long. And it is.
cat logfile | tail -561 > logfile.tmp
logfile.tmp should be 561 lines long. It is still only 559 lines.
cat logfile | tail -2000 > logfile.tmp
logfile.tmp should be 850 lines long (i.e. unmodified). Yet it has been truncated to 559 lines.
cat logfile | se -e :a -e '$q:N,2001,$D;ba' > logfile.tmp.
This logfile.tmp is correct. But I don't understand the strange sed syntax. I just pulled it off the net. I don't trust it because I don't understand it.
So my question:
Any idea why "tail -559 works" and "tail -561" fails? It this is some type of memory limitation, why does that strange sed command work?
K570 HP9000 HPUX11.0
steve
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2005 06:32 AM
03-07-2005 06:32 AM
SolutionIf you are uncomfortable with the sed command then craft a Perl or awk equivalent.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2005 06:38 AM
03-07-2005 06:38 AM
Re: broken tail? tail -559 works. tail -561 fails.
From the man page:
"Tails relative to end-of-file are stored in a 20-Kbyte buffer, and thus are limited in length."
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2005 08:26 AM
03-07-2005 08:26 AM
Re: broken tail? tail -559 works. tail -561 fails.
I ran
tail -n 580 logfile > f1
tail -n 590 logfile > f2
tail -n 200000 logfile > f3
ls -l f?
I see the file size for files f1, f2 and f3 are ALL 20468 bytes.
#LEN=total lines of logfile
#TAILN=the total I want it to be
#L=the starting line for the awk.
LEN=`wc -l logfile | cut -f1 -d\ `
TAILN=800
L=`expr $LEN - $TAILN`
if [ $L -le 0 ] ; then
cat logfile
else
cat logfile | \
awk -v L=$L '// { if (NR < L) print ;}' > f4
File f4 is 28420 bytes, and 800 lines long.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2006 06:38 AM
01-25-2006 06:38 AM
Re: broken tail? tail -559 works. tail -561 fails.
tail -n +
With "tail -n <# lines>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2006 03:12 AM
01-26-2006 03:12 AM