The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep and delete lines except the lines with strings vj8436 Shell Programming and Scripting 14 04-17-2009 11:25 AM
How to delete first 5 lines and last five lines in all text files ragavendran31 Shell Programming and Scripting 10 02-21-2008 07:58 AM
How to delete more lines kamathg Shell Programming and Scripting 1 10-05-2007 06:39 AM
delete blank lines or lines with spaces only vascobrito UNIX for Dummies Questions & Answers 3 01-13-2004 07:36 AM
delete lines.. alisevA3 UNIX Desktop for Dummies Questions & Answers 8 05-29-2002 08:33 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-31-2008
suryanarayana suryanarayana is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 15
How to delete matter in between two lines

help

I am having text file like this...

------------------------END OF UPDATION ------------------
xxxxxxxxxxxxxxxxxxxxxxxxx
yyyyyyyyyyyyyyyyyyyyy
yyyyyyyyyyyyyyyyyyyyy

1 row updated
------------------------END OF UPDATION ------------------
TTTTTTTTTTTTTTTT
FFFFFFFFFFFFFFFFF

0 rows updated
------------------------END OF UPDATION ------------------
UUUUUUUUUUUUUUUUUU
SSSSSSSSSSSSSSSSSSS
1 row updated
------------------------END OF UPDATION ------------------


i want to delete the matter in which text is having 0 rows updated
in between two lines...and even lines also....



i.e


------------------------END OF UPDATION ------------------
TTTTTTTTTTTTTTTT
FFFFFFFFFFFFFFFFF

0 rows updated
------------------------END OF UPDATION ------------------



advance happy new year
  #2 (permalink)  
Old 12-31-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Try this:

Code:
awk '/END OF UPDATION/{s=$0;next}{s=s "\n" $0}
/0 rows updated/{print s;getline;print}
' file
Regards
  #3 (permalink)  
Old 01-02-2009
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,078
#! /usr/bin/perl
undef $/;
open FH,"<a.txt";
$str=<FH>;
@arr=split("------------------------END OF UPDATION ------------------",$str);
print "------------------------END OF UPDATION ------------------\n";
for($i=1;$i<=$#arr;$i++){
@tmp=split("\n",$arr[$i]);
print $arr[$i] if (!($tmp[$#tmp]=~/0 row/));
}
print "------------------------END OF UPDATION ------------------\n";
close FH;
  #4 (permalink)  
Old 01-03-2009
suryanarayana suryanarayana is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 15
will u pls explain...hw will it work
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0