- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Delete first lines from text file
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
12-26-2002 09:15 AM
12-26-2002 09:15 AM
Delete first lines from text file
I want to delete the first lines from text file and keep only the last 50 lines of the file. How can I do it ? Using sed ?
Cheers,
Mauro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2002 09:24 AM
12-26-2002 09:24 AM
Re: Delete first lines from text file
You can use tail -50 fichname > fichtmp
Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2002 09:24 AM
12-26-2002 09:24 AM
Re: Delete first lines from text file
tail -50 filename > newname
-USA..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2002 09:38 AM
12-26-2002 09:38 AM
Re: Delete first lines from text file
With sed is like:
num=`wc -l fich| cut -d" " -f1`
(( num1=num - 50 ))
sed -e ''$num1','$num'd' fich
Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2002 09:40 AM
12-26-2002 09:40 AM
Re: Delete first lines from text file
You must observe that in this line:
sed -e ''$num1','$num'd' fich
before $ character are two ' characters and not one ".
Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2002 10:08 AM
12-26-2002 10:08 AM
Re: Delete first lines from text file
I just want to open the file, delete the lines and close it without distroying the file because this file is a log file and a process writes in this file continuosly if I have to rename to a temp file and then back it to orginal name this process will lose the point.
Thanks once more,
Mauro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2002 10:31 AM
12-26-2002 10:31 AM
Re: Delete first lines from text file
tail -50 logfile > newfile
cat newfile > logfile
This won't close the pointer to the file. You have a slight risk of loosing data if it was written to the log file after the "tail" but before the "cat" command.