info grabbing from a column with grep, awk or sed -
i have following tabel:
^2num^5|^2score^5|^2ping^5 | ^2status ^5| ^2name players ^5| ^2address ---- ------- ------ -------- -------------------- -----------------------^7 ^5 0 ^2|^3 41 ^2|^3 100 ^2|^5 player ^2|^7just cr4zy name! ^2|^77.18.76.12:58641 ^3[^5fr^3]^7 ^5 2 ^2|^3 3 ^2|^3 57 ^2|^3 bot ^2|^7^8bot1 ^2|^7bot ^5 3 ^2|^3 7 ^2|^3 43 ^2|^3 bot ^2|^7^8bot2 ^2|^7bot ^5 4 ^2|^3 18 ^2|^3 16 ^2|^3 bot ^2|^7^8bot3 ^2|^7bot ^5 5 ^2|^3 2 ^2|^3 103 ^2|^5 player ^2|^7just ^5cr4zy n4me2! ^2|^784.18.8.144:27960 ^3[^5il^3]^7 ^5 6 ^2|^3 18 ^2|^3 102 ^2|^3 bot ^2|^7^8bot4 ^2|^7bot ^5 7 ^2|^3 29 ^2|^3 102 ^2|^3 bot ^2|^7^8bot5 ^2|^7bot ^5 8 ^2|^3 39 ^2|^3 54 ^2|^3 bot ^2|^7^8bot ^2|^7bot ^5 9 ^2|^3 24 ^2|^3 77 ^2|^3 bot ^2|^7^8bot ^2|^7bot ^510 ^2|^3 10 ^2|^3 103 ^2|^3 bot ^2|^7^8bot ^2|^7bot ^511 ^2|^3 42 ^2|^3 95 ^2|^3 bot ^2|^7^8bot ^2|^7bot ^512 ^2|^3 2 ^2|^3 103 ^2|^5 player ^2|^7ju5t ^5cr4zy ^7name3! ^2|^722.185.55.9:13565 ^3[^5il^3]^7 ^513 ^2|^3 24 ^2|^3 96 ^2|^3 bot ^2|^7^8bot ^2|^7bot ^514 ^2|^3 0 ^2|^3 51 ^2|^3 bot ^2|^7^8bot ^2|^7bot ^2-------------------------------------------------------------------------^7 ^5bots : ^311 ^5, players : ^33 ^5, : ^314
i grab info per line: num , address every column starts , ends color code not need. in column 1, starts ^5 , ends ^2 lines bot can skipped.
output prefer:
0 77.18.76.12 5 84.18.8.144 12 22.185.55.9
seperate have number of players displayed in last line.
preferable sed, grep or awk
thank in advance.
in awk:
$ awk 'match($0,/([0-9]{1,3}\.){3}[0-9]{1,3}/) { print substr($0,3,2),substr($0,rstart,rlength) } 0 77.18.76.12 5 784.18.8.144 12 722.185.55.9
if there ip looking string in record, print
it , characters 3 , 4 beginning of record. naturally fail if player uses ip address name.
a separate script count players:
$ awk 'match($0,/([0-9]{1,3}\.){3}[0-9]{1,3}/) { i++ } # player counter end{ print "players : " i+0 }' file
Comments
Post a Comment