- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Perl Help
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
тАО12-20-2004 03:25 PM
тАО12-20-2004 03:25 PM
I am trying to delete the first 15 lines from each text file I have. Is there a easy perl script for this?
The attached file is similar to the text file I am working with. It is always going to be the first 15 lines.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2004 04:00 PM
тАО12-20-2004 04:00 PM
Re: Perl Help
perl -ni.orig -e 'print if $. > 15'
It should delete first 15 lines in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2004 04:14 PM
тАО12-20-2004 04:14 PM
Re: Perl Help
I tried this since I am trying to run it for over 1000 files at once. But what is happening is that it only update the first file.
perl -i -n -e 'print if$. > 15;' *.txt
What could I be doing wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2004 04:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2004 07:23 PM
тАО12-20-2004 07:23 PM
Re: Perl Help
foreach $file (glob "*.txt") {
@ARGV=$file;
$^I=".bak";#creates backup with .bak extension
while (<>) {
if ($.>15) {
print;
}
}
}
By the way for any perl question refer to:
www.perlmonks.org
Best and quick answers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-20-2004 08:43 PM
тАО12-20-2004 08:43 PM
Re: Perl Help
http://www-106.ibm.com/developerworks/linux/library/l-p102.html
http://www.unixguide.net/unix/perl_oneliners.shtml
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-21-2004 07:28 AM
тАО12-21-2004 07:28 AM
Re: Perl Help
# delete first 10 lines
├В ├В perl -i.old -ne 'print unless 1 .. 10' foo.txt
Is there a easy way to run it for a bunch of files at once?
Does it matter what shell I am
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-21-2004 11:59 AM
тАО12-21-2004 11:59 AM
Re: Perl Help
See for example:
http://www.rice.edu/web/perl-edit.html
The only tricky part with that iss to recognize file transitions, where you'll need to reset the line number for the work you want to do.
So a solution might be:
perl -ni.old -e 'print unless ($.<10); close ARGV if eof' *.txt
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-23-2004 02:01 AM
тАО12-23-2004 02:01 AM
Re: Perl Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2005 09:49 AM
тАО01-09-2005 09:49 AM