- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- UNIX COMMAND TO TRIM LOG FILES
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
тАО06-18-2001 01:33 PM
тАО06-18-2001 01:33 PM
But that did not work. It would only work for a number not larger than 200 lines.
Any suggestions?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-18-2001 02:28 PM
тАО06-18-2001 02:28 PM
SolutionYou can usw 'wc' to calculate the number of lines in your file, and then compute the line number from which you want to "save forward". For instance:
# LINES=`wc -l < myfile`
# let LINES=$LINES-100 # to remove the first 100 lines...
# sed -n $LINES,'$p' myfile > myfile.trimmed
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-18-2001 09:01 PM
тАО06-18-2001 09:01 PM
Re: UNIX COMMAND TO TRIM LOG FILES
it's very easy.
#tail -l 1000 "logfile" > newlog
#cp newlog logfile
best of luck
kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2001 05:46 AM
тАО06-19-2001 05:46 AM
Re: UNIX COMMAND TO TRIM LOG FILES
Thanks for your input. When I try your solution I only get a maximum of 229 lines in the trimmed file. The original file has over 8000 lines.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2001 05:57 AM
тАО06-19-2001 05:57 AM
Re: UNIX COMMAND TO TRIM LOG FILES
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2001 05:59 AM
тАО06-19-2001 05:59 AM
Re: UNIX COMMAND TO TRIM LOG FILES
##
### Utility Menu to Manage the System Log
####
#####
syslog=/var/adm/syslog/syslog.log
## cp $syslog $syslog.orig
clear
print -n "
Manage the System Log: $syslog
1. View --> Read the System Log File
2. Count --> Tally the number of ERRORS and WARNINING
3. Trim --> Empty the Log File
4. Display --> Show Size of the System Log File
5. Exit --> Exit this Program
Select from the menu: "
read pick
case "$pick" in
1| [Vv] ) tail -200 $syslog | more ; manage ;;
2| [Cc] ) errors=$(grep -c -e ERROR $syslog)
warns=$(grep -c -e WARNING $syslog)
((total=errors+warns))
print "There are $total Errors or Warnings in the $syslog" ;;
3| [Tt] ) print "Clearing the $syslog"
cp -p $syslog /var/adm/syslog/syslog.log.$(date +%m%d%y)
> $syslog ;;
4| [Dd] ) ls -l /var/adm/syslog/syslog.log | awk '{print $5}' ;;
5| [Ee] ) exit ;;
esac
exit
Hope this helps.
Rob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2001 07:16 AM
тАО06-19-2001 07:16 AM
Re: UNIX COMMAND TO TRIM LOG FILES
Thank you
I have not used the sed command before. It looks like it will take care of what I need
Thanks Again