If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > uniq command help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-14-05, 11:31
shehzad_manekia shehzad_manekia is offline
Registered User
 
Join Date: Feb 2004
Posts: 30
uniq command help

I have a textfile and i want to search for a duplicate line in that file and delete that duplicate line plus the next 5 lines after that.

Can any one help?

Thanks
Reply With Quote
  #2 (permalink)  
Old 11-17-05, 09:29
ducasio ducasio is offline
Registered User
 
Join Date: Aug 2004
Location: Rome, Italy
Posts: 81
hi,
with uniq I don't think(if I am not wrong) it can be done what you want. I tryed it with awk and it worked. Try this:

-----------------------------------------------------
awk 'BEGIN{i=10}{if(prev==$0)i=1; if(i>7&&prev!="") print prev; prev=$0;i=i+1}' my_file.txt
----------------------------------------------------

I hopes it works for you as well.
bye,
ducasio
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On