如合搜尋當天第一筆時間前的資訊 - Linux

By Tracy
at 2016-04-06T23:20
at 2016-04-06T23:20
Table of Contents
BEGIN{
p_id="";
id="";
p_date="";
}
/^ *[0-9]/{
p_id=id;
id=$2
}
/^ Time/{
if ($2" "$3 != p_date) {
if (p_date != ""){
printf("last record of %s: %d\n",gensub(/start:/,"","1",p_date),p_id)
printf("1st record of %s: %d\n",gensub(/start:/,"","1",$2)" "$3,id)
}
p_date=$2" "$3
}
}
※ 引述《nashsai (納許賽)》之銘言:
: Hi
: 我有一個文件為
: --------------------------------------------------------
: % id status user
: ---------------------------------
: 0 140 complete auser
: Details:
: Time start:Apr 6,2016 18:14:35
: % id status user
: ---------------------------------
: 0 141 complete buser
: Details:
: Time start:Apr 6,2016 18:45:35
: .
: .
: .
: .
: -------------------------------------------------------
: id是按照時間排的.
: 我想知道每天的第一筆ID與最後一筆ID
: 要使用什麼方法來做比較快
: 目前想到可能是搜到第一筆 日期(ex: Apr 6)時 印出前兩行 然後awk print $2
: 最後一筆可能用隔天的id-1
: 不知道我的想法對嘛
: 請各位看看 感謝
--
p_id="";
id="";
p_date="";
}
/^ *[0-9]/{
p_id=id;
id=$2
}
/^ Time/{
if ($2" "$3 != p_date) {
if (p_date != ""){
printf("last record of %s: %d\n",gensub(/start:/,"","1",p_date),p_id)
printf("1st record of %s: %d\n",gensub(/start:/,"","1",$2)" "$3,id)
}
p_date=$2" "$3
}
}
※ 引述《nashsai (納許賽)》之銘言:
: Hi
: 我有一個文件為
: --------------------------------------------------------
: % id status user
: ---------------------------------
: 0 140 complete auser
: Details:
: Time start:Apr 6,2016 18:14:35
: % id status user
: ---------------------------------
: 0 141 complete buser
: Details:
: Time start:Apr 6,2016 18:45:35
: .
: .
: .
: .
: -------------------------------------------------------
: id是按照時間排的.
: 我想知道每天的第一筆ID與最後一筆ID
: 要使用什麼方法來做比較快
: 目前想到可能是搜到第一筆 日期(ex: Apr 6)時 印出前兩行 然後awk print $2
: 最後一筆可能用隔天的id-1
: 不知道我的想法對嘛
: 請各位看看 感謝
--
Tags:
Linux
All Comments

By Jacob
at 2016-04-10T12:11
at 2016-04-10T12:11

By David
at 2016-04-14T02:19
at 2016-04-14T02:19

By Carolina Franco
at 2016-04-16T12:58
at 2016-04-16T12:58

By Ivy
at 2016-04-18T01:48
at 2016-04-18T01:48

By Suhail Hany
at 2016-04-21T23:34
at 2016-04-21T23:34

By Emily
at 2016-04-25T05:23
at 2016-04-25T05:23

By Edward Lewis
at 2016-04-28T12:32
at 2016-04-28T12:32

By Wallis
at 2016-04-30T13:49
at 2016-04-30T13:49

By Kelly
at 2016-05-05T11:15
at 2016-05-05T11:15

By Hamiltion
at 2016-05-06T15:42
at 2016-05-06T15:42

By Selena
at 2016-05-11T06:10
at 2016-05-11T06:10

By Frederic
at 2016-05-14T09:39
at 2016-05-14T09:39

By Steve
at 2016-05-17T22:55
at 2016-05-17T22:55
Related Posts
如合搜尋當天第一筆時間前的資訊

By Franklin
at 2016-04-06T22:12
at 2016-04-06T22:12
請問linux可以玩百變恰吉嗎XD?

By Todd Johnson
at 2016-04-05T13:29
at 2016-04-05T13:29
好幾行stdout一次只處理一行內的數字

By Yedda
at 2016-04-05T11:33
at 2016-04-05T11:33
有關BtrFS Array建立前的分割問題

By Daph Bay
at 2016-04-05T10:59
at 2016-04-05T10:59
好幾行stdout一次只處理一行內的數字

By Ophelia
at 2016-04-05T10:05
at 2016-04-05T10:05