Okay here is my predicament!
I have two ASCII files containing words.
The files are structured like this
værktøj p418.spr
væv p446.spr
walkman p444.spr
wc papir p141.spr
wc p140.spr
One has the words in a foreign language and one has them in english
The two files have one thing in common and that is the pxxx.spr placed after each word/words.
The phrase pxxx.spr (where xxx is any random number) points to a specific picture which is the same picture in whichever language when we are talking about the same word.
The difference between the two is that the English file contains several (i.e. a lot) of words that are irrelevant.
What I need to do is therefore to find a way to replace each of the foreign words with the corresponding English word in a clean file. All off course based upon the foreign file which is the most current file.
I think the logical way to go about it would be the following way.
Read the Foreign text file, identify the first pxxx.spr
Copy that particular pxxx.spr to a new file
Read the English text file, find pxxx.spr
Copy the English word in front of pxxx.spr to the new file by inserting the word to the new file containing the English word in a manner that would look something like this:
ENGLISHWORD1 pxxx.spr
Next I would go back to reading the foreign text file, identify the next pxxx.spr...
Then follow same procedure as above, put ENGLISHWORD1 and pxxx.spr into the new file below the first one - then find the third pxxx.spr etc. all the way untill the end of the foreign file producing a file that would look something like this:
ENGLISHWORD1 pxxx.spr
ENGLISHWORD2 pxxx.spr
ENGLISHWORD3 pxxx.spr
ENGLISHWORD4 pxxx.spr
ENGLISHWORD5 pxxx.spr
ENGLISHWORD6 pxxx.spr
ENGLISHWORD7 pxxx.spr
Thus I would have produced a new file containing the English words without all the extra words contained in the old English text file and a file that corresponded in content to the foreign text file.
I am 100% certain that this can be done via the command line using commands such as grep cat etc. as these are simple text files we are talking about and if anyone can help me out by solving this one he/she will have done me/us a huge favor.
You can copy the above foreign text example and save it as the foreign file, and then use the below example as the English file. (clutter included)
tools p418.spr
baboon p999.spr
loom p446.spr
banana p566.spr
walkman p444.spr
toilet paper p141.spr
toilet p140.spr
I am only posting this due to severe time constraints on my part and wouldn't ask for help unless I needed it at this moment in time!
This is not homework - This is something I need to take care of in support of the charity
http://globability.org to which I belong - and which I am currently directing toward OpenSource development.
Please refrain from asking me to go figure - RTFM or any of the sort... well you know what I mean
If you are willing to take the challenge do post a reply - If not please ignore this post entirely!!!