Sponsored Content
Top Forums Shell Programming and Scripting How to delete lines using sed? Post 302508127 by cgkmal on Saturday 26th of March 2011 03:58:20 AM
Old 03-26-2011
Try with the opposite of a known sed oneliner ("print paragraph if it contains pattern"), I've adapted it to your
case ("
print paragraph if it not contains pattern").

I'm not sure exactly how it works, but it does:


Code:
sed -e '/./{H;$!d;}' -e 'x;/sachin.com/d;' inputfile

or more compressed:
sed -e '/./{H;$!d;};x;/sachin.com/d;' inputfile

 Reference: http://sed.sourceforge.net/sed1line.txt

Regards

Last edited by cgkmal; 03-26-2011 at 05:07 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete multiple lines w/ sed

Hi all, I am trying to figure out the syntx to delete multiple lines w/ sed. I know the following syntax will delete lines 1 THROUGH 5 from filex: sed 1,5d filex But I wan to delete lines 1 AND 5 (keeping lines 2,3, and 4). Does anyone know how to do this in a single sed statement? ... (2 Replies)
Discussion started by: bookoo
2 Replies

2. Shell Programming and Scripting

sed help - delete last 2 lines.

I have been reading through the sed one liners, trying to understand what is happening. # delete the last 2 lines of a file sed 'N;$!P;$!D;$d' The above will delete the last 2 line of a file. I tried analyzing what happens. And I got lost :( This is what I understood so far from the... (2 Replies)
Discussion started by: vino
2 Replies

3. Shell Programming and Scripting

Delete lines containing text with sed

hello all I have bunch of files containing lines of text that surrounding by <# .......#> tags I like to delete this lines from the text files whiteout open the files , can it be done with sed ? or other unix tool (perl mybe )? (2 Replies)
Discussion started by: umen
2 Replies

4. Shell Programming and Scripting

delete blank lines with sed

I have a text file with blank lines fullfilled with spaces and others only containing the "Enter" caracter, the \012. I would like to eliminate all them with the sed command. Is it possible? making: sed '/^$/d' <file should delete the blank lines but doesn't work for the lines that only... (2 Replies)
Discussion started by: tmxps
2 Replies

5. Shell Programming and Scripting

sed problem - delete all lines until a match on 2 lines

First of all, I know this can be more eassily done with perl or other scripting languages but, that's not the issue. I need this in sed. (or wander if it's possible ) I got a file (trace file to recreate the control file from oracle for the dba boys) which contains some lines another line... (11 Replies)
Discussion started by: plelie2
11 Replies

6. Shell Programming and Scripting

Using SED to delete some lines from file

Hi All, I have one /etc/hosts.equiv file which has following entries ########## wcars42g admin wcars42b netmgr wcars42b oemssrvr wcars42f admin wcars42f netmgr wcars42f oemssrvr ########## I am trying to delete lines starting from wcars42b.... (1 Reply)
Discussion started by: akash_mahakode
1 Replies

7. Shell Programming and Scripting

Sed to delete lines that with the following

Hi, I'm very new to Sed and I have a very large file that contains data in the following way (*064) 1 4 10 (*064) simulation time = 0.12000E-05 (*064) 1 2 10 (*064) 1 3 10Essentially what I want to do it delete every line that starts with '(*064) 1'I tried the following, ... (2 Replies)
Discussion started by: lost.identity
2 Replies

8. Shell Programming and Scripting

Delete lines with SED in Bash?

Hello everyone I'm doing a program in bash and wanted to know how can I do to delete document lines the words not ending in S with SED, ie, show only those ending with the letter S. I probe with: sed -e /$.*/d "$file" | more to delete all lines NOT ending in S but not work!... (3 Replies)
Discussion started by: adiegorpc
3 Replies

9. Shell Programming and Scripting

Sed/awk to delete single lines that aren't touching other lines

Hello, I'm trying to figure out how to use sed or awk to delete single lines in a file. By single, I mean lines that are not touching any other lines (just one line with white space above and below). Example: one two three four five six seven eight I want it to look like: (6 Replies)
Discussion started by: slimjbe
6 Replies

10. Shell Programming and Scripting

sed or awk: delete n lines following a formfeed

Hi Members, This is my first post in this forum. I want to do is match form feed lines one by one in a file and delete the next n lines (ex-3 lines) with the form feed character Eg - Files looks like Data 1 Data 2 Data 3 FF Hdr1 Hdr2 Hdr3 Data4 Data5 FF Hdr1 Hdr2 Hdr3 (9 Replies)
Discussion started by: yohan
9 Replies
Catalyst::Engine::Apache2::MP20(3pm)			User Contributed Perl Documentation		      Catalyst::Engine::Apache2::MP20(3pm)

NAME
Catalyst::Engine::Apache2::MP20 - Catalyst Apache2 mod_perl 2.x Engine SYNOPSIS
# Set up your Catalyst app as a mod_perl 2.x application in httpd.conf PerlSwitches -I/var/www/MyApp/lib # Preload your entire application PerlModule MyApp <VirtualHost *> ServerName myapp.hostname.com DocumentRoot /var/www/MyApp/root <Location /> SetHandler modperl PerlResponseHandler MyApp </Location> # you can also run your app in any non-root location <Location /some/other/path> SetHandler perl-script PerlResponseHandler MyApp </Location> # Make sure to let Apache handle your static files # (It is not necessary to remove the Static::Simple plugin # in production; Apache will bypass Static::Simple if # configured in this way) <Location /static> SetHandler default-handler </Location> # If not running at a root location in a VirtualHost, # you'll probably need to set an Alias to the location # of your static files, and allow access to this location: Alias /myapp/static /filesystem/path/to/MyApp/root/static <Directory /filesystem/path/to/MyApp/root/static> allow from all </Directory> <Location /myapp/static> SetHandler default-handler </Location> </VirtualHost> DESCRIPTION
This is the Catalyst engine specialized for Apache2 mod_perl version 2.x. ModPerl::Registry While this method is not recommended, you can also run your Catalyst application via a ModPerl::Registry script. httpd.conf: PerlModule ModPerl::Registry Alias / /var/www/MyApp/script/myapp_registry.pl/ <Directory /var/www/MyApp/script> Options +ExecCGI </Directory> <Location /> SetHandler perl-script PerlResponseHandler ModPerl::Registry </Location> script/myapp_registry.pl (you will need to create this): #!/usr/bin/perl use strict; use warnings; use MyApp; MyApp->handle_request( Apache2::RequestUtil->request ); METHODS
ok_constant OVERLOADED METHODS
This class overloads some methods from "Catalyst::Engine". unescape_uri OVERLOADED METHODS
This class overloads some methods from "Catalyst::Engine". unescape_uri SEE ALSO
Catalyst, Catalyst::Engine, Catalyst::Engine::Apache2. AUTHORS
o Sebastian Riedel <sri@cpan.org> o Christian Hansen <ch@ngmedia.com> o Andy Grundman <andy@hybridized.org> o Tomas Doran <bobtfish@bobtfish.net> COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by The "AUTHORS". This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.10.1 2010-11-26 Catalyst::Engine::Apache2::MP20(3pm)
All times are GMT -4. The time now is 08:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy