LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 05-16-2011, 08:23 AM   #1
cocostaec
LQ Newbie
 
Registered: May 2011
Posts: 9

Rep: Reputation: 0
finding and remove block of identical strings


i have a problem in finding block of identical strings...i solved the problem in finding consecutive identical words and now i want to expand the code in order to find and remove consecutive identical block of strings...
for example the awk code removing consecutive identical word is:
Code:
#!/usr/bin/awk -f
BEGIN{			
    RS="[[:space:]]+";
    ORS="" 
}
match($0,/^([[:punct:]]*)([^[:punct:]]+)([[:punct:]]*)$/,f){ 
  if(x != f[2])
  {
    print y$0;z = FNR
  }
  x = f[2];
  y = RT
}
END{
  if(z != FNR)
  print f[3]"\n"
}
input:
"ana are mere mere
mere si portocale
ion are prune prune."

output:
"ana are mere si portocale
ion are prune."

and now i want to expand the code to do the following:
input:
"ana are ana are mere
ion are prune ion are prune"

output:
"ana are mere
ion are prune"

thanks

Last edited by cocostaec; 05-16-2011 at 11:00 AM. Reason: Added code tags to prevent emoticon recognition and parsing.
 
Old 05-16-2011, 08:52 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,564

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
Please place code in [code][/code] tags as this is practically illegible.
 
Old 05-20-2011, 07:24 AM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread should be closed because it is a duplicate.

Pending closure by the mods assigned to this forum, please post all answers here:
http://www.linuxquestions.org/questi...trings-881603/
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can not match strings that appear to be identical dnoob Programming 4 02-27-2011 12:42 PM
Grep -- finding files that contain two separate strings Fliggerty Linux - Newbie 4 12-10-2010 09:40 AM
block strings with pf. posible? what about other firewalls ? da1 *BSD 1 06-21-2007 09:29 AM
Is it possible to block text strings with IP tables? abefroman Linux - Security 27 06-29-2005 06:36 PM
remove identical lines in a file benjithegreat98 Linux - General 4 04-24-2004 07:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration