LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 07: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 10:00 AM. Reason: Added code tags to prevent emoticon recognition and parsing.
 
Old 05-16-2011, 07:52 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Please place code in [code][/code] tags as this is practically illegible.
 
Old 05-20-2011, 06: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



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 11:42 AM
Grep -- finding files that contain two separate strings Fliggerty Linux - Newbie 4 12-10-2010 08:40 AM
block strings with pf. posible? what about other firewalls ? da1 *BSD 1 06-21-2007 08:29 AM
Is it possible to block text strings with IP tables? abefroman Linux - Security 27 06-29-2005 05:36 PM
remove identical lines in a file benjithegreat98 Linux - General 4 04-24-2004 06:12 AM

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

All times are GMT -5. The time now is 09:32 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
Open Source Consulting | Domain Registration