- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: triming a file contents
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
04-28-2003 12:32 AM
04-28-2003 12:32 AM
triming a file contents
Could there be an hp unix command to trim specific(range of) contents of a file created without deleting the entire contents of such file?Example, to get rid of contents of a log file generated earlier without getting rid of those generated lately.
Nsikan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 12:38 AM
04-28-2003 12:38 AM
Re: triming a file contents
depends what you want
look at
split - split a file into pieces
tail - deliver the last part of a file
and script it
steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 12:48 AM
04-28-2003 12:48 AM
Re: triming a file contents
I don't really know a pure tool to do it, but concerning log files, sam can do it. Look in routine tasks, system log files. Here you can add your own log files defining a "recommended size" and sam will be able to trim it (to zero, to the recommended size or to a given size).
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 12:49 AM
04-28-2003 12:49 AM
Re: triming a file contents
#sed -n '1,10000p' file-name >/tmp/a
which should take first 10000 lines to /tmp/a
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 01:00 AM
04-28-2003 01:00 AM
Re: triming a file contents
There is no specific command for this but yes you can use sed, tail,head cmd's in scripts and write your own scripts to do this.
sed is good command you can see
man sed
for more info.
Sunil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 01:22 AM
04-28-2003 01:22 AM
Re: triming a file contents
Add 2 tasks in your crontab -
One will run at midnight every night say - will take a backup copy of the log say /var/logfile and place it in say /tmp/lastnight.log.
Second one will run at say 23:59:59 (if that's possible or just 23:59:00) every night, the following command -
# comm -3 /var/logfile /tmp/lastnight.log > /tmp/today.log
Starting from tomorrow night, the current day's log entries alone will be placed in /tmp/today.log. Fine tune this if you wish - the above times are just examples, with no great Sys Admin knowledge.
Of course, you would like to know more about the comm utility - so "man comm".
HTH.
- ramd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 03:38 AM
04-28-2003 03:38 AM
Re: triming a file contents
split -b 56m source_file dest
split -b 55752k ... ...
split -b 55752316 ... ...
Also a line unit of measure:
http://docs.hp.com/cgi-bin/fsearch/framedisplay?top=/hpux/onlinedocs/B9106-90007/B9106-90007_top.html&con=/hpux/onlinedocs/B9106-90007/00/03/325-con.html&toc=/hpux/onlinedocs/B9106-90007/00/03/325-toc.html&searchterms=split&queryid=20030428-053714
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2003 03:48 AM
04-28-2003 03:48 AM
Re: triming a file contents
Of all these things the cron to move the files to a daily version and then use find with mtime +2 or so to delete the old ones will work most simly.Cron means you never forget to run it.
What files are you talkin about.
steve Steel