ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Now not all entry’s are in order this is only an example.
Any help would be appreciated I have been struggling with this for 2 days now, I can match some of the entry’s but have a problem with the doubles and my file 3 gets huge. The file format is all in csv.
I was thinking of reading file 1 line by line then matching it to file 2 line by line and writing the output to file 3, then removing that match line from file 1 and 2, if more than 1 entry exist it might match later on with another entry.
The second problem is not all the numbers do not match fully in some entry's, but if I can match those that do so long I can work on the non matching ones later.
No problem me 2. Yes that is what the current code is doing in a lame way. I have been experimenting with while loop (while read line cre.csv do …) but I get stuck with the second while loop for deb.csv. Meaning I have a while loop with in a while loop (not the best way I think) plus when I do the loop the output file grows at an enormous rate meaning something is definitely wrong.
What I have done is with the first while loop is to read the first line in the cre.csv file then in the second while loop try and match it with a line in deb.csv print both query and match to the output file and remove them from cre.csv and deb.csv so that it can’t the matched in again. The other problem is if more than one match exists in deb.csv to output that as well plus if cre.csv has a double. How to handle the doubles is a big problem.
Very nice…. I ran it now and for the most part it is working. Now and again it comes up with “line 8: [: too many arguments” but I think that is because of the deb.csv file that has some text in the last field… I will play around with your code a bit. Thanks
I'm a little confused. Could you give us an example by example for every kind of match? What type of match gets "match", what type of match gets "match2", "Double" and so on. Would there be "match3" as well? Please elaborate.
In short the OP means: match the numbers in the last column of the lines in the first file with the numbers of the last column of the second file and if it matches print both lines and append a string which marks from which file the line is.
That is correct, if no match occurs then leave the entry in the file and carry on to the next. This means at the end of the filtering / matching possess i will have one file with the quarry and match's and the cre and deb file with the entry's that does not match. We could even move those entry's that does not match out to another file it does not matter. The append string is also not of grate importance it is a nice to have.
This does seem like a nice quick way to match, although it does not know what to do with the double entry's and reuse entry's that has been used already, but i think i must read a bit more on the man pages. Maybe this can help more with the non-matching... Awesome, Thanks