Quote:
Originally Posted by cristi32
i dont know how.
i want a script to parse the file from the beggining and when it view an IP , it keep the first line with this IP, all other lines with the same IP must be deleted . the next IP, the same thing like with the first IP.
please help
|
@cristi32, you realize that you're asking someone to just jump up and do effort for you.
That's not the idea of LQ or really any forum like this. People are here of their own accord, not paid, and not obligated to take on efforts, and especially not when you repeatedly write "please help". (And if that phrase is part of your signature, remove it)
People will however be very detailed and very helpful if you start on your own, demonstrate that you are not asking someone to do all the work for you, but instead demonstrate that you are willing to participate in your own answer.
My read on this is either of (1) you don't know how to start at all, or (2) you're unwilling to start and would rather just have someone do this all for you.
As are as option #2 goes, TenTenth's point is highly applicable here:
Quote:
Originally Posted by TenTenths
Ok, so what have you tried so far?
|
Assuming you're willing to give option #1 a go, my recommendation is ultimately to write a BASH script.
First follow the advices of TenTenths and TBOne and determine what commands you'd use on your log file to make the determinations which will selectively find the information you want, try those commands out, try some variations on those commands.
Once you've determined how to do this on the command line, then you can write those commands into a script.
There are many resources available regarding how to script. I have a
blog entry which covers some of this as well, and I feel an important point I make in that entry is that "everything you can do on a regular command line, you can write in a bash script". Further, if you check the links in my signature, and probably many other's, you'll see reference links for bash scripting.
As far as needing help with that, if/when you post things to the effect of "I've tried <command example> on <example data>, and I got <some-result>, however I really wanted to get <desired-result>" then people will be more willing to assist you.
Another part of all this is that the inquirer may not always know exactly what they want, or once they get some of what they want, their need for further refinement grows exponentially. So as a result, you say "I need to find all occurrences of the letter "e". Someone responds "blah-blah", done! Next you say "I need to find all occurrences of the letter "e" only when followed by a "th", and only on even numbered lines, in files which were made the third Tuesday of any given month, on a leap year." Wow! Right? Yes an exaggeration, but that is sometimes what ends up happening.
Therefore it's best that you participate in your own solution so that when it invariably comes time to modify that solution, you understand how the solution is being executed and you can intelligently steer it towards the modifications which best suit you.