delete first 100 lines from a file


 
Thread Tools Search this Thread
Operating Systems Solaris delete first 100 lines from a file
# 8  
Old 06-09-2009
Quote:
Originally Posted by Franklin52
Should be:

Code:
sed "/^SG/d" file

Regards
Thanks All. It worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Delete Some Lines from File

Hi, I have a txt document having a format like this: DATA1 | DATA2 | DATA3 | 23-JAN-20 23:41:34 DATA1 | DATA2 | DATA3 | 23-JAN-20 23:41:32 DATA1 | DATA2 | DATA3 | 23-JAN-20 23:41:30 ... DATA1 | DATA2 | DATA3 | 23-JAN-20 22:35:31 DATA1 | DATA2 | DATA3 | 23-JAN-20 22:30:34 DATA1 | DATA2 |... (1 Reply)
Discussion started by: gc_sw
1 Replies

2. Shell Programming and Scripting

Delete 40 lines after every 24 lines from a file

Hello, I have file of more than 10000 lines. I want to delete 40 lines after every 20 lines. e.g from a huge file, i want to delete line no from 34 - 74, then 94 - 134 etc and so on. Please let me know how i can do it. Best regards, (11 Replies)
Discussion started by: nehashine
11 Replies

3. UNIX for Advanced & Expert Users

Delete first 100 lines from a BIG File

Hi, I need a unix command to delete first n (say 100) lines from a log file. I need to delete some lines from the file without using any temporary file. I found sed -i is an useful command for this but its not supported in my environment( AIX 6.1 ). File size is approx 100MB. Thanks in... (18 Replies)
Discussion started by: unohu
18 Replies

4. UNIX for Advanced & Expert Users

In a huge file, Delete duplicate lines leaving unique lines

Hi All, I have a very huge file (4GB) which has duplicate lines. I want to delete duplicate lines leaving unique lines. Sort, uniq, awk '!x++' are not working as its running out of buffer space. I dont know if this works : I want to read each line of the File in a For Loop, and want to... (16 Replies)
Discussion started by: krishnix
16 Replies

5. UNIX for Dummies Questions & Answers

How get only required lines & delete the rest of the lines in file

Hiiii I have a file which contains huge data as a.dat: PDE 1990 1 9 18 51 28.90 24.7500 95.2800 118.0 6.1 0.0 BURMA event name: 010990D time shift: 7.3000 half duration: 5.0000 latitude: 24.4200 longitude: 94.9500 depth: 129.6000 Mrr: ... (7 Replies)
Discussion started by: reva
7 Replies

6. Shell Programming and Scripting

How to delete lines in a file that have duplicates or derive the lines that aper once

Input: a b b c d d I need: a c I know how to get this (the lines that have duplicates) : b d sort file | uniq -d But i need opossite of this. I have searched the forum and other places as well, but have found solution for everything except this variant of the problem. (3 Replies)
Discussion started by: necroman08
3 Replies

7. UNIX for Dummies Questions & Answers

Delete same lines out of file.

hello... I have a file with a list of filepaths in it, like so: delMe.txt (files to be deleted) ./root/index.php ./root/language/se/home.inc.php ./root/language/pl/home.inc.php Now here's what I'm trying to do. I want any lines in the above file (delMe.txt) to be deleted out of the... (3 Replies)
Discussion started by: jzacsh
3 Replies

8. Shell Programming and Scripting

Please help to delete lines in a file

Dear All, I m trying to delete two lines at a time in file called 123.txt. Im using sed and based on line numbers i m deleting it and writing it to another file. Follwing i have done. cat 123.txt | sed '1,5 d' > new I want to delete line no 1 and 5 at a time, for that i m using... (6 Replies)
Discussion started by: naree
6 Replies

9. Solaris

delete first 100 lines rather than zero out of file

Hi experts, in my solaris 9 the file- /var/adm/messeages growin too first. by 24 hours 40MB. And always giving the below messages-- bash-2.05# tail -f messages Nov 9 16:35:38 ME1 last message repeated 1 time Nov 9 16:35:38 ME1 ftpd: wtmpx /var/adm/wtmpx No such file or directory Nov 9... (7 Replies)
Discussion started by: thepurple
7 Replies

10. UNIX for Dummies Questions & Answers

delete all lines in file

how can i delete all lines in file by using "vi" ? (6 Replies)
Discussion started by: strok
6 Replies
Login or Register to Ask a Question
Paranoid::Input(3pm)					User Contributed Perl Documentation				      Paranoid::Input(3pm)

NAME
Paranoid::Input - Paranoid input functions VERSION
$Id: Input.pm,v 0.20 2011/04/13 22:01:43 acorliss Exp $ SYNOPSIS
use Paranoid::Input; FSZLIMIT = 64 * 1024; LNSZLIMIT = 2 * 1024; $rv = slurp($filename, @lines); $rv = sip($filename, @lines); $rv = sip($filename, @lines, 1); $rv = tail($filename, @lines); $rv = tail($filename, @lines, -100); $rv = tail($filename, @lines, -100, 1); $rv = closeFile($filename); addTaintRegex("telephone", qr/(d{3})s+d{3}-d{4}/); $rv = detaint($userInput, "login", $val); $rv = stringMatch($input, @strings); DESCRIPTION
The modules provide safer routines to use for input activities such as reading files and detainting user input. The sip and tail functions keep open file handles. Even so, it's specifically built to be safe for use in fork scenarios. You can being a tail or sip in a parent, fork children, and all process can independently continue sipping with no confusion between processes. This is possible because we check to see if the PID matches the PID in effect with the file was opened. If not, we reopen the file and seek to the same position so we can pick up where we left off. The slurp function isn't affected by this since it reads entire files in a single call, no filehandles are kept open between calls. All file-reading functions use and obey flock. addTaintRegex is only exported if this module is used with the :all target. SUBROUTINES
/METHODS FSZLIMIT The value returned/set by this lvalue function is the maximum file size that will be read into memory. This affects functions like slurp (documented below). Unless explicitly set this defaults to 16KB. LNSZLIMIT The valute returned/set by this lvalue function is the maximum line length supported by functions like sip (documented below). Unless explicitly set this defaults to 2KB. slurp $rv = slurp($filename, @lines); This function allows you to read a text file in its entirety into memory, the lines of which are placed into the passed array reference. This function will only read files up to FSZLIMIT in size. Flocking is used (with LOCK_SH) and the read is a blocking read. An optional third argument sets a boolean flag which, if true, determines if all lines are automatically chomped. If chomping is enabled this will strip both UNIX and DOS line separators. The return value is false if the read was unsuccessful or the file's size exceeded FSZLIMIT. In the latter case the array reference will still be populated with what was read. The reason for the failure can be retrieved from Paranoid::ERROR. sip $rv = sip($filename, @lines); $rv = sip($filename, @lines, 1); This function allows you to read a text file into memory in chunks, the lines of which are placed into the passed array reference. The chunks are read in at up to FSZLIMIT in size at a time. Like slurp file locking is used and autochomping is also supported. This function returns true if there was input read, but if any or all of the input splits into lines greater than LNSZLIMIT it will discard that input and return -1 (which is still technically boolean true). The reason why we now care about line lengths is because it's very likely that line boundaries will not fall neatly along our chunk boundaries, so we need to take trailing portions of unterminated lines and store them to be joined with the remainder from the next sip. When sip comes up to then end of the file it does not close the file, you're required to close it explicitly with closeFile. This is done intentionally to allow the process to continue to effectively tail a growing file. Unlike the tail function provided here, though, it does perform any additional checks to see if the file you're reading was truncated or replaced. An optional third argument tells sip whether or not to chomp all the read lines before returning. tail $rv = tail($filename, @lines); $rv = tail($filename, @lines, -100); $rv = tail($filename, @lines, -100, 1); The only difference between this function and sip is that tail opens the file and immediately seeks to the end. If an optional third argument is passed it will seek backwards to extract and return that number of lines (if possible). Depending on the number passed one must be prepared for enough memory to be allocated to store LNSZLIMIT * that number. This function returns true if the file is successfully open, regardless of whether any new input was there to be read. It only returns false if there was a problem opening or reading the file. Tail should be called with the third argument for the first tail of a file. Continuing to use it for subsequent calls will cause the number of lines returned to be truncated to fit within that limit. Like sip, one must explicitly close a file with closeFile. closeFile $rv = closeFile($filename); This function closes any open file descriptors that may have been opened via sip or tail for the named file. This returns the value of the close function if the file was open, otherwise it returns true. addTaintRegex addTaintRegex("telephone", qr/(d{3})s+d{3}-d{4}/); This adds a regular expression which can used by name to detaint user input via the detaint function. This will allow you to overwrite the internally provided regexes or as well as your own. detaint $rv = detaint($userInput, "login", $val); This function populates the passed reference with the detainted input from the first argument. The second argument specifies the type of data in the first argument, and is used to validate the input before detainting. The following data types are currently known: alphabetic ^([a-zA-Z]+)$ alphanumeric ^([a-zA-Z0-9])$ email ^([a-zA-Z][w.-]*@ (?:[a-zA-Z0-9][a-zA-Z0-9-]*.)* [a-zA-Z0-9]+)$ filename ^[/ w-.:,@+]+[?$ fileglob ^[/ w-.:,@+*?{}[]]+[?$ hostname ^(?:[a-zA-Z0-9][a-zA-Z0-9-]*.)* [a-zA-Z0-9]+)$ ipaddr ^(?:d+.){3}d+$ netaddr ^(?:d+.){3}d+(?:/(?:d+| (?:d+.){3}d+))?$ login ^([a-zA-Z][w.-]*)$ nometa ^([^`$!@]+)$ number ^([+-]?[0-9]+(?:.[0-9]+)?)$ If the first argument fails to match against these regular expressions the function will return 0. If the string passed is either undefined or a zero-length string it will also return 0. And finally, if you attempt to use an unknown (or unregistered) data type it will also return 0, and log an error message in Paranoid::ERROR. NOTE: This is a small alteration in previous behavior. In previous versions if an undef or zero-length string was passed, or if the data type was unknown the code would croak. That was, perhaps, a tad overzealous on my part. stringMatch $rv = stringMatch($input, @strings); This function does a multiline case insensitive regex match against the input for every string passed for matching. This does safe quoted matches (Q$stringE) for all the strings, unless the string is a perl Regexp (defined with qr//) or begins and ends with /. NOTE: this performs a study in hopes that for a large number of regexes will be performed faster. This may not always be the case. DEPENDENCIES
o Fcntl o Paranoid o Paranoid::Debug BUGS AND LIMITATIONS
If you fork a process that's already opened a file with sip or tail a new file descriptor will be opened for the child process. But what may be less obvious is that with a newly opened file descriptor you will be starting back from the beginning (or end, in the case of tail) of the file, rather than from where ever you were before the fork. AUTHOR
Arthur Corliss (corliss@digitalmages.com) LICENSE AND COPYRIGHT
This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information. (c) 2005, Arthur Corliss (corliss@digitalmages.com) perl v5.14.2 2011-04-13 Paranoid::Input(3pm)