awk

Find the durations and their average between the dataset in an interval in shell script

大憨熊 提交于 2020-01-16 03:50:09
问题 This is related to my older question Find the durations and their maximum between the dataset in an interval in shell script I have a dataset as: ifile.txt 2 3 2 3 2 20 2 0 2 0 0 2 1 2 5 6 7 0 3 0 3 4 5 I would like to find out different duration and their average between the 0 values in 6 values interval. My desire output is: ofile.txt 6 5.33 1 2 1 2 1 2 5 4.2 1 3 3 4 Where 6 is the number of counts until next 0 within 6 values (i.e. 2,3,2,3,2,20) and 5.33 is the average value among them; 1

Printing column from a string in bash

前提是你 提交于 2020-01-16 03:37:07
问题 UPDATED QUESTION Ok, so I have a file with lines like this: 44:) 2.884E-02 0.000E+00 0.000E+00 2.780E+02 0.000E+00 0.000E+00 9.990E+02 45:) 2.884E-02 0.000E+00 0.000E+00 2.780E+02 0.000E+00 0.000E+00 9.990E+02 1:) 3.593E-02 0.000E+00 0.000E+00 2.780E+02 0.000E+00 0.000E+00 1.000E+05 2:) 3.593E-02 0.000E+00 0.000E+00 2.780E+02 0.000E+00 0.000E+00 1.000E+05 The numbers in the first column run from 1 to x (in this case 45) and then starts over at 1 lots of times. I want to move some of the

weblogic access.log日志常见分析

随声附和 提交于 2020-01-16 03:10:24
1,查看apache进程: ps aux | grep httpd | grep -v grep | wc -l // ps aux是显示所有进程和其状态。 2,查看80端口的tcp连接: netstat -tan | grep "ESTABLISHED" | grep ":80" | wc -l 3,通过日志查看当天ip连接数,过滤重复: cat access_log | grep "19/May/2011" | awk '{print $2}' | sort | uniq -c | sort -nr 4,当天ip连接数最高的ip都在干些什么(原来是蜘蛛): cat access_log | grep "19/May/2011:00" | grep "61.135.166.230" | awk '{print $7}' | sort | uniq -c | sort -nr | head -n 10 5,当天访问页面排前10的url: cat access_log | grep "19/May/2010:00" | awk '{print $7}' | sort | uniq -c | sort -nr | head -n 10 6,用tcpdump嗅探80端口的访问看看谁最高 tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F".

awk to calculate number of days between two dates:

你。 提交于 2020-01-16 01:17:55
问题 Would like to calculate number of days between two dates , for the below example, No of days == $6-$4 position. Input.txt Desc1,Desc2,Desc3,DATE_ACTIVE,STATEMENT_DATE,Desc4 abc,def,ghi,21-MAR-08,01-JUL-14,jkl abc,def,ghi,01-JUL-14,15-JUL-14,jkl abc,def,ghi,06-NOV-06,08-JUL-14,jkl abc,def,ghi,18-NOV-03,08-JUL-14,jkl abc,def,ghi,14-JUN-06,15-JUL-14,jkl Desired Output: Desc1,Desc2,Desc3,DATE_ACTIVE,STATEMENT_DATE,Desc4,No_Of_Days abc,def,ghi,21-MAR-08,01-JUL-14,jkl,2293 abc,def,ghi,01-JUL-14,15

awk reduce decimals for a single multiple input values

大兔子大兔子 提交于 2020-01-15 18:52:08
问题 I want to transform the following 82.77, 69.30, 43.75, 33.44, 26.88, 26.83, 24.89, 24.88, 24.74, 23.07, 19.31 into 82.8, 69.3, 44.0, 33.4, 26.8, ... I think awk seems to be the easy way to do this. The following does work for a single input value echo 123.45567 | awk '{printf("%.1f\n", $1)}' How can I do this for the above multiple input values with the space delimiter with awk or is there any better way to do this? Yesterday I was trying with java script which didn't work. 回答1: Just loop

awk reduce decimals for a single multiple input values

牧云@^-^@ 提交于 2020-01-15 18:50:56
问题 I want to transform the following 82.77, 69.30, 43.75, 33.44, 26.88, 26.83, 24.89, 24.88, 24.74, 23.07, 19.31 into 82.8, 69.3, 44.0, 33.4, 26.8, ... I think awk seems to be the easy way to do this. The following does work for a single input value echo 123.45567 | awk '{printf("%.1f\n", $1)}' How can I do this for the above multiple input values with the space delimiter with awk or is there any better way to do this? Yesterday I was trying with java script which didn't work. 回答1: Just loop

awk embedded script issue (unexpected character '\')

时光怂恿深爱的人放手 提交于 2020-01-15 13:06:22
问题 I use an embedded awk code in a shell script: I have some variable assignments at the BEGIN part of it: \ BEGIN { FS=","; OFS=","; service_not="false"; end_of_line="\n"; is_setup_gps="false"; \ \ a=6378137.0 ; \ b=6356752.3142 ; \ f=(a-b)/a ; \ e=sqrt(f*(2-f)) ; \ } \ \ So I need '\' at the end of each line (to have an entire awk script embedded in .sh). BUT: for the lines: a=...; b=...; f=...; the '\' causing errors...: mawk: 57: unexpected character '\' Why? UPD: Embedding of awk in the

awk embedded script issue (unexpected character '\')

岁酱吖の 提交于 2020-01-15 13:04:01
问题 I use an embedded awk code in a shell script: I have some variable assignments at the BEGIN part of it: \ BEGIN { FS=","; OFS=","; service_not="false"; end_of_line="\n"; is_setup_gps="false"; \ \ a=6378137.0 ; \ b=6356752.3142 ; \ f=(a-b)/a ; \ e=sqrt(f*(2-f)) ; \ } \ \ So I need '\' at the end of each line (to have an entire awk script embedded in .sh). BUT: for the lines: a=...; b=...; f=...; the '\' causing errors...: mawk: 57: unexpected character '\' Why? UPD: Embedding of awk in the

awk embedded script issue (unexpected character '\')

时光总嘲笑我的痴心妄想 提交于 2020-01-15 13:02:16
问题 I use an embedded awk code in a shell script: I have some variable assignments at the BEGIN part of it: \ BEGIN { FS=","; OFS=","; service_not="false"; end_of_line="\n"; is_setup_gps="false"; \ \ a=6378137.0 ; \ b=6356752.3142 ; \ f=(a-b)/a ; \ e=sqrt(f*(2-f)) ; \ } \ \ So I need '\' at the end of each line (to have an entire awk script embedded in .sh). BUT: for the lines: a=...; b=...; f=...; the '\' causing errors...: mawk: 57: unexpected character '\' Why? UPD: Embedding of awk in the

Parse the large test files using awk

不打扰是莪最后的温柔 提交于 2020-01-15 12:22:57
问题 I am looking to parse a space delimited input text file using awk. The column code can have more than one row for each group. I would greatly appreciate any help with this. Input File: TR 1 Action Success/Failure 8.1.1.1 RunOne 80 48 8.1.1.2 RunTwo 80 49 8.1.1.3 RunThree 100 100 8.1.1.4 RunFour 20 19 8.1.1.5 RunFive 20 20 Action Time 16:47:42 Action2 Success/Failure 8.1.2.1 RunSix 80 49 8.1.2.2 RunSeven 80 80 8.1.2.3 RunEight 80 80 Action2 Time 03:26:31 TR 2 Action Success/Failure 8.1.1.1