Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to remove first 100 line in a file? Post 302338762 by glen.barber on Tuesday 28th of July 2009 09:38:14 PM
Old 07-28-2009
Let's not forget about:
Code:
d100d

in Vi. Smilie

Note: Yes, I do know the OP did not want to actually open the file. Just putting it out there for the archives.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove header(first line) and trailer(last line) in ANY given file

Hi, I need some help in removing the header (first line) and the trailer (last line) in a give file... The data file actually comes in EBCDIC format and I converted it into ASCII.. Now I need to strip off the first line and the last line.. I think we can use sed to do something like this:... (2 Replies)
Discussion started by: madhunk
2 Replies

2. Shell Programming and Scripting

How to remove last line of the file

hi sir, i need help..how to remove last line of the each file for example i have files a.txt ,b.txt and so on..i wanted to delete last list of each file..the patten not same for each file..any help? thanks in advance (3 Replies)
Discussion started by: mani_um
3 Replies

3. UNIX for Dummies Questions & Answers

remove a line within a file

Hi all, i have a text file similar to belowA1 A2 A3 B1 ... .... *** # first occurance B1 ... .... *** # second occurance B1 ... .... *** # third occurance My desired output is B1 ... .... *** # second occurance B1 ... .... *** # third occurance I want to remove the first line that is after... (3 Replies)
Discussion started by: new2ss
3 Replies

4. Shell Programming and Scripting

Remove a line from a file

Hi ,guys. I have one question: I want to write a script which removes a line with certain string from a file, for example The name of the file is: "passwd", the contents of it is below: ************************* ... brownj2:x:5000: hynesp:x:5001: leeb:x:5002 dioxna:x:5003 ... ... (2 Replies)
Discussion started by: daikeyang
2 Replies

5. Shell Programming and Scripting

How to remove a line from a file

./xxibe ./xxibe/11.5.0 ./xxibe/11.5.0/admin ./xxcyb/11.5.0/reports/US ./xxkintana ./xxkintana/1016454 ./xxkintana/1016454/backup ./xxkintana/1016454/updates ./xxcpf/11.5.0/xml_gw ./xxcse ./xxcse/11.5.0 ./xxcse/11.5.0/admin I have a file (sample.txt) this file contains above text. I... (9 Replies)
Discussion started by: gagan4599
9 Replies

6. Shell Programming and Scripting

Remove first line of file

Is there an easy way to remove the first line of a file so that the file: aaron benjamin cecilia daniel elliot fernando would become benjamin cecilia daniel elliot fernando (4 Replies)
Discussion started by: locoroco
4 Replies

7. Shell Programming and Scripting

How to remove last line of the file

Hi, unix gurus, I need to remove last line of the file. anybody can help me thanks in advance (7 Replies)
Discussion started by: ken002
7 Replies

8. Shell Programming and Scripting

Remove line from file and read file line by line

I have a file output.txt. File looks like this name1 10 name2 2 name3 5 I get a number n and I need to remove all lines which has number (after name) smaller or equal to n number. After that I need to write lines from file and my output must be like this: Output: 'name1 10' Output: 'name2... (1 Reply)
Discussion started by: kubo12312
1 Replies

9. UNIX for Beginners Questions & Answers

Remove first line of file

How can I use bash to remove the first line of a file? (3 Replies)
Discussion started by: locoroco
3 Replies
Perl::Critic::Policy::InputOutput::RequireBriefOpen(3)	User Contributed Perl Documentation Perl::Critic::Policy::InputOutput::RequireBriefOpen(3)

NAME
Perl::Critic::Policy::InputOutput::RequireBriefOpen - Close filehandles as soon as possible after opening them. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
One way that production systems fail unexpectedly is by running out of filehandles. Filehandles are a finite resource on every operating system that I'm aware of, and running out of them is virtually impossible to recover from. The solution is to not run out in the first place. What causes programs to run out of filehandles? Usually, it's leaks: you open a filehandle and forget to close it, or just wait a really long time before closing it. This problem is rarely exposed by test systems, because the tests rarely run long enough or have enough load to hit the filehandle limit. So, the best way to avoid the problem is 1) always close all filehandles that you open and 2) close them as soon as is practical. This policy takes note of calls to "open()" where there is no matching "close()" call within "N" lines of code. If you really need to do a lot of processing on an open filehandle, then you can move that processing to another method like this: sub process_data_file { my ($self, $filename) = @_; open my $fh, '<', $filename or croak 'Failed to read datafile ' . $filename . '; ' . $OS_ERROR; $self->_parse_input_data($fh); close $fh; return; } sub _parse_input_data { my ($self, $fh) = @_; while (my $line = <$fh>) { ... } return; } As a special case, this policy also allows code to return the filehandle after the "open" instead of closing it. Just like the close, however, that "return" has to be within the right number of lines. From there, you're on your own to figure out whether the code is promptly closing the filehandle. The STDIN, STDOUT, and STDERR handles are exempt from this policy. CONFIGURATION
This policy allows "close()" invocations to be up to "N" lines after their corresponding "open()" calls, where "N" defaults to 9. You can override this to set it to a different number with the "lines" setting. To do this, put entries in a .perlcriticrc file like this: [InputOutput::RequireBriefOpen] lines = 5 CAVEATS
"IO::File->new" This policy only looks for explicit "open" calls. It does not detect calls to "CORE::open" or "IO::File->new" or the like. Is it the right lexical? We don't currently check for redeclared filehandles. So the following code is false negative, for example, because the outer scoped filehandle is not closed: open my $fh, '<', $file1 or croak; if (open my $fh, '<', $file2) { print <$fh>; close $fh; } This is a contrived example, but it isn't uncommon for people to use $fh for the name of the filehandle every time. Perhaps it's time to think of better variable names... CREDITS
Initial development of this policy was supported by a grant from the Perl Foundation. AUTHOR
Chris Dolan <cdolan@cpan.org> COPYRIGHT
Copyright (c) 2007-2011 Chris Dolan. Many rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module perl v5.16.3 2014-06-09 Perl::Critic::Policy::InputOutput::RequireBriefOpen(3)
All times are GMT -4. The time now is 01:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy