Splitting the source file as per the code(1st substring) in 4th(AcctID) column
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
there is no need to write script, grep will do it by itself.
as I told you already: grep --file=lookup-file input-file > output-file
just you need to use the lookup file I posted. see man grep about details (of --file)
Depending on how large the files sizes are, perl language could be a good candidate too
But I agree with pan64, grep and creation of patterns files looks appealing with 4 lines of code to solve the whole problem
Hey sorry but I am not sure how grep will work when we will getting different codes on every run, suppose we have 100 codes in a main file are we grepping all 100 codes in script, I am not sure if it works.
Hey sorry but I am not sure how grep will work when we will getting different codes on every run, suppose we have 100 codes in a main file are we grepping all 100 codes in script, I am not sure if it works.
You've been shown quite a few examples by various members. Please understand that you stand to raise the frustration level of them if you seemingly don't appear to be trying any of their suggestions. There are plenty of things you can do to test and debug, much of which I imagine you have done a bit of. I'd suggest that you update your fellow members with some progress with a few attempt updates. People are not here to do these tasks literally for you, we are here to help you to learn and do for yourself. You can use a smaller set of data to test a few tactics and then run it on your larger files. Bear in mind that I don't know everything about awk, it is one of my weakest "non-talents" in the Unix/Linux world. However when I choose to use it, or the tr command, I perform a web search saying exactly what I wish to do with the command. And if I've been too particular, I wean it down to be "how do I split a line with awk", "how do I print the 5th field with awk", and so forth. As you get to use LQ more and eventually offer advice to fellow members, you'll appreciate those who, while they have questions, they also work with some diligence at attaining their solution. Also, you'll feel much more satisfied if you partake an active role in solving your problem, you will own part of that solution, if not most of it.
Quote:
Originally Posted by bishnumnnit2006
The only issue is with the performance, so if you have any alternate solution please come out with the script, Many Thanks.
I wrote all of the above from your earlier reply. This that you just wrote is now bordering on rudeness towards forum members. Please consider what I've written above. If you feel that LQ members are here to hand you solutions, then this is not a forum where you can attain the help you are seeking.
You also persist with failing to put your code within [code] tags to properly separate it and retain formatting.
Hey sorry but I am not sure how grep will work when we will getting different codes on every run, suppose we have 100 codes in a main file are we grepping all 100 codes in script, I am not sure if it works.
this is why one should and some do, write the code, in a command line or script, does not matter, then test it with some actual data pulled out of the chuck of it all and placed into a secure location so it does not effect the normal process.
even just that one grep line that is said that is all you need, then place it into a file by whatever name so you do not have to keep rewriting the entire line all of the time, just the filename to get it to do its work.
one shouldn't do anything like this on production runs without first testing it.
As you have been аsked, please place your code snippets inside [CODE]...[/CODE] tags for better readability. You may type those yourself or click the "#" button in the edit controls.
You have received much good advice, including complete examples of how to approach your problem, but have not shown any effort of your own to use, or even consider the help provided. You persist in asking for others to provide complete solutions for you. This is not how LQ works.
Please review the Site FAQ for guidance in posting your questions and general forum usage.
We are happy to help, but if you are looking for others to do your work for you, this is not the place.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.