@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet


Comments:

<0> hello
<1> hi
<2> hey
<0> How do I print out a line, if the next line matches the same IP addres-string?
<2> do you mean print the previous line to the match?
<0> yes
<0> well they wont fully match
<0> ClientConnect: 0 (IP: 212.33.92.6:29070)
<0> ClientConnect: 1 (IP: 83.31.122.63:29070)
<0> ClientConnect: 2 (IP: 85.147.177.98:29070)



<2> according to the sed1line.txt:
<2> sed -n '/regexp/{g;1!p;};h'
<0> I wanna know if 2 IP's are the same
<2> oh
<2> well, i could probaly kludge together something that would work but i'm sure others here know of a much better way to do it. :-P
<0> any quick easy tutorial?
<0> all these faqs are so damn hard :(
<2> have you looked at the sed1line.txt?
<2> search for duplicate
<2> you may be able to customize something there to your needs
<2> if you only need to know if there are duplicates, you could just pipe the IPs to wc -l and the compare that to uniq | wc -l
<0> no
<0> cus people connect all the time
<0> I wanna know if people connect twice
<0> probably using an exploit to crash the server
<2> i don't know of any quick and easy solution. sorry
<0> okay
<1> Lubse: beginning idea is to remove \n from each line and print the new lines so lines 1 2,2 3,3 4,etc are printed; sed -n 'H;0~1{x;s/\n/ /g;p}' filename
<1> Lubse: then find a way to see if the IP: whatever is the same on those new lines
<0> thats gonna be a very long line xD
<2> i'm having trouble staying focused correctly because sql commands keeps poping into mind :-(
<1> Lubse: from your posted example line 1 would be: ClientConnect: 0 (IP: 212.33.92.6:29070) ClientConnect: 1 (IP: 83.31.122.63:29070)
<0> yes
<0> but my server log has about a milion connections
<1> ok
<0> in a years time
<1> Lubse: ask nicely in #bash or you will get flamed but some sharp ppl there might help
<0> okay
<0> #bash
<2> i was setting connection limits in my firewall until i added a photo album and people kept getting blacklisted trying to look at it
<0> lol
<2> ;-)
<1> Lubse: sed -n 'H;0~1{x;s/\n/ /g;p}' url |awk '{if ($4 == $8)print $0}' #ClientConnect: 2 (IP: 85.147.177.98:29070) ClientConnect: 2 (IP: 85.147.177.98:29070)
<1> Lubse: url is filename
<0> >
<0> ?
<0> ah
<0> thanks
<0> !!!
<0> works! :D



<3> omg.
<3> Blasphemy!
<1> goldfish: what's the correct way to do it? ;)
<3> Dunno.
<3> I was just joking anyways.
<1> goldfish: you read lubse's entrys on this chan?
<1> basically he wants to test a file for sequentical entrys with the same IP address and print only those lines or ideally just the ip addy
<3> Oh right.
<3> uniq -d , comes to mind, but the file would need to be sorted.
<3> Sure, there's loads of ways you could do it, whatever works.
<3> I did this one day though -- but it's blasphemy as it's not sed
<3> #compare previous $1, if equal ignore, else print
<3> awk '{if(NR==1){cur=$1;print;next}if($1!=cur){print};cur=$1}'
<1> thanks
<4> what kind of command is next
<5> An awk command. :)
<3> Sorry :/
<3> I should learn how to do that in sed, though, and stop being lazy.
<1> sed -n 'H;0~1{x;s/\n/ /g;p}' filename |awk '{if ($4 == $8)print $4}' #works ok
<3> yeah. Mais, je deteste les pipelines!
<1> oops, pipeline-o-phobic ;)
<5> What's the question again?
<1> compare previous $1, if $1 in next line is equal print the line, else do not print
<1> sed -n 'H;0~1{x;s/\n/ /g;p}' filename |awk '{if ($4 == $8)print $4}' #works ok
<5> /\([^ ]*\).*\n\1/
<1> prec: sed -n '/\([^ ]*\).*\n\1/' sed: -e expression #1, char 17: missing command
<5> yes, that's the pattern to use to match the first columns of two lines.
<5> I leave the rest of the program as an "exercise for the reader"
<5> :P
<3> lol
<5> Hint, the H command is involved, etc.
<1> thanks
<5> H and P and D
<5> Did ya get it?
<5> I have time now ... :P
<3> he legged it!
<5> meh, OK.
<6> how acn i get the first character of a string?
<3> sed 's/\(.\).*/\1/
<3> Your shell could do it for you also.
<6> how?
<3> what shell?
<6> bash
<3> a="string"; echo "${a:0:1}"
<6> that reads a from index 0 inclusive to 1 exclusive?
<3> ${var:start:length}


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #sed
or
Go to some related logs:

#oe
cocoasql tutorial
gnome disable f1
slavik insults
mount dvd ubuntu
#bash
i fucking hate printers
fedora bitchx gmake ctcp.o error
I need perl-SDL installed
#suse



Home  |  disclaimer  |  contact  |  submit quotes