English 中文(简体)
如何印刷IP_ADDRESS:在指挥前的编号
原标题:how to print IP_ADDRESS:port # before sed command
  • 时间:2012-04-06 18:46:14
  •  标签:
  • bash

是否容易印刷IP_Address:port# ? 由于我刚到塞德的指挥所去,港口被 stripped除。

input file example

Apr 6 14:20:41 TCP 178.255.83.1:80 in

preferred output like this

Apr 6 14:20:41 TCP 178.255.83.1:80 in United Kingdom
egrep -w  TCP|UDP  $Denied_IPs |
sed  s/:[^:]* in/ in/; s/:[^:]* out/ out/  |
awk  {cmd="echo "$5" | code | fgrep  Country:  | cut -c 16-43";
      cmd | getline rslt;
      close(cmd);
      print $1" "$2" "$3" "$4" "$5" "$6" "rslt}  >> "$IP2COUNTRY"
最佳回答

The sed command is stripping the port explicitly. Given that that is all the sed command is doing, simply remove it from the expression.

这样就能够以一种不乐观的方式执行。 特别是在删除<条码>后,<条码>,<条码>>>> 可在<代码>wk上加方括号:

awk  / (TCP|UDP) / {
       split($5, addr, /:/);
       cmd = "echo " addr[1] " | code | fgrep Country: | cut -c 16-43";
       cmd | getline rslt;
       close(cmd);
       print $1, $2, $3, $4, $5, $6, rslt
     }  < "$Denied_IPs" >> "$IP2COUNTRY"

我可以提供帮助,但认为在<条码>上援引<条码><>/代码>。 可优化。

(我也删除了<代码>上的单一引文。) 国家:没有用处,如果需要had<>/em>,则实际上会打断文字,因为整件已经用单一文字包装。

问题回答

暂无回答




相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...