LinuxQuestions.org
Review your favorite Linux distribution.
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


Reply
  Search this Thread
Old 05-10-2011, 03:18 PM   #1
pklcnu
LQ Newbie
 
Registered: Jan 2009
Posts: 5

Rep: Reputation: 0
How to retrieve the text difference between two strings having substrings


Dear Experts

I got requirement to find the difference between two strings and write the difference to new file by comparing the substrings separted by commas

Below mentioned is an example of requirement

String1 --> ABC,DEF,GHI,JKL
String2 --> MNO,ABC,XYZ,DEF

In String1 and String2 the substrings are separted by commas. The substrings which are common between String1 and String2 are ABC,DEF this common substrings has to be written to a file say common.txt ( having the text ABC,DEF). And the substrings GHI,JKL in String1 which are not present in String2 has to be written to another file say String1Extra.txt (having the text GHI,JKL). In the same way the substrings MNO,XYZ from String2 which are not present in String1 has to be written to another file say String2Extras.txt(having the text MNO,XYZ) .

How to achieve this ?

Many thanks in advance for your help
 
Old 05-10-2011, 04:35 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,322

Rep: Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470Reputation: 4470
Quote:
Originally Posted by pklcnu View Post
Dear Experts
I got requirement to find the difference between two strings and write the difference to new file by comparing the substrings separted by commas Below mentioned is an example of requirement

String1 --> ABC,DEF,GHI,JKL
String2 --> MNO,ABC,XYZ,DEF

In String1 and String2 the substrings are separted by commas. The substrings which are common between String1 and String2 are ABC,DEF this common substrings has to be written to a file say common.txt ( having the text ABC,DEF). And the substrings GHI,JKL in String1 which are not present in String2 has to be written to another file say String1Extra.txt (having the text GHI,JKL). In the same way the substrings MNO,XYZ from String2 which are not present in String1 has to be written to another file say String2Extras.txt(having the text MNO,XYZ) .

How to achieve this ?
Many thanks in advance for your help
This sounds VERY much like homework.

What have you tried/done thus far?? What programming language are you using? The methods of doing this differ between bash, perl, ruby, etc., so what is your 'requirement' for the language?
 
  


Reply


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
Text file manipulation: alphanumeric strings CHARL0TTE Linux - Newbie 2 07-10-2009 10:40 AM
Retrieve a text file? InfinitePalindrome Linux - Newbie 1 06-23-2008 11:18 PM
How to store text(strings) in a 2D character array reading from a text file(C++) bewidankit Programming 3 02-14-2008 08:08 AM
How to search for text strings? armandino LQ Suggestions & Feedback 2 06-24-2007 08:51 PM
Is it possible to block text strings with IP tables? abefroman Linux - Security 27 06-29-2005 06:36 PM

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

All times are GMT -5. The time now is 10:03 PM.

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