- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Trimming the file size
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
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
тАО09-21-2009 09:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 10:09 AM
тАО09-21-2009 10:09 AM
SolutionGiven that you know the first line number in the file after which you don't want anything kept, do by example:
# sed -e 200,$d' file
In this example, I wanted to start deleting at the 200th line until the end of the file.
Remember that 'wc -l file' offers you the count of the number of total lines in a file.
You may also want to revisit your similar, earlier question on this topic:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1367025
Regards!
...JRF../
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 10:16 AM
тАО09-21-2009 10:16 AM
Re: Trimming the file size
Thx for ur quick and valuable reply...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 10:17 AM
тАО09-21-2009 10:17 AM
Re: Trimming the file size
- Open the file in vi .
- go to the position at before last 1000 lines. ( You can see current line position by Ctrl +g ) [ To go to a particular line Esc :Linenumber ]
- Esc 1000dd #It will delete 1000 lines from there.
- Save and exit vi.
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 11:08 AM
тАО09-21-2009 11:08 AM
Re: Trimming the file size
Also chekc this out:
Even you dont know the first line number in the file after which you want to delete:
# To delte last 1000 lines of the file:
1. # cat filename | sed -e :a -e '$d;N;2,1000ba' -e 'P;D' > trimmed_file.out
2. # cat filename | cat -n | sort -rn | cut -c8- | sed -e '1,1000d' | cat -n | sort -rn | cut -c8- > trimmed_file.out
Cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 10:05 PM
тАО09-21-2009 10:05 PM
Re: Trimming the file size
The best option is sed
In this example, sed will delete lines 1-10 of the output:
$ sed -e '1,1000d' /tmp/myfile
When we separate two addresses by a comma, sed will apply the following command to the range that starts with the first address, and ends with the second address. In this example, the 'd' command was applied to lines 1-10, inclusive. All other lines were ignored.
you can give 20,30 or any range.
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-22-2009 12:28 AM
тАО09-22-2009 12:28 AM
Re: Trimming the file size
Here is an ex(1) solution:
ex <<\EOF file
$-999,$d
wq
EOF