set 設定變數空格消失 - BBS
By Todd Johnson
at 2011-06-05T17:13
at 2011-06-05T17:13
Table of Contents
請問
date -v -1H "+%b %_d %H"
出現的結果是
Jun 5 16
^^這裡有空格
但是若我將結果變成變數
set packtime=`date -v -1H "+%b %_d %H"`
echo $packtime
Jun 5 16
^空格少一個 請問有辦法解決嗎?
我是要用在grep查詢 少一個空格就查不到了
cat /var/log/filter.log | grep 'date "+%b %_d %H"'
資料內容是這樣的
Jun 5 12:59:58 pfsense pf: 122.96.58.54.39124 > 114.43.203.127.21819: UDP, length 23
Jun 5 12:59:58 pfsense pf: 00:00:00.028174 rule 1/0(match): block in on pppoe0: (tos 0x0, ttl 121, id 224, offset 0, flags [
Jun 5 12:59:58 pfsense pf: 118.166.195.219.55362 > 114.43.203.127.21819: Flags [S], cksum 0xfb1c (correct), seq 86550498
Jun 5 12:59:59 pfsense pf: 00:00:00.592545 rule 1/0(match): block in on pppoe0: (tos 0x0, ttl 116, id 25902, offset 0, flags
Jun 5 12:59:59 pfsense pf: 124.11.64.120.64283 > 114.43.203.127.21819: Flags [S], cksum 0x0d0c (correct), seq 2623128094
Jun 5 13:00:00 pfsense pf: 00:00:01.364355 rule 1/0(match): block in on pppoe0: (tos 0x0, ttl 110, id 31094, offset 0, flags
Jun 5 13:00:00 pfsense pf: 122.96.58.54.39124 > 114.43.203.127.21819: UDP, length 23
Jun 5 13:00:02 pfsense pf: 00:00:01.560724 rule 1/0(match): block in on pppoe0: (tos 0x0, ttl 116, id 26057, offset 0, flags
Jun 5 13:00:02 pfsense pf: 124.11.64.120.64283 > 114.43.203.127.21819: Flags [S], cksum 0x0d0c (correct), seq 2623128094
我要把上一個個小時的LOG檔封存起來
麻煩指導
謝謝
--
date -v -1H "+%b %_d %H"
出現的結果是
Jun 5 16
^^這裡有空格
但是若我將結果變成變數
set packtime=`date -v -1H "+%b %_d %H"`
echo $packtime
Jun 5 16
^空格少一個 請問有辦法解決嗎?
我是要用在grep查詢 少一個空格就查不到了
cat /var/log/filter.log | grep 'date "+%b %_d %H"'
資料內容是這樣的
Jun 5 12:59:58 pfsense pf: 122.96.58.54.39124 > 114.43.203.127.21819: UDP, length 23
Jun 5 12:59:58 pfsense pf: 00:00:00.028174 rule 1/0(match): block in on pppoe0: (tos 0x0, ttl 121, id 224, offset 0, flags [
Jun 5 12:59:58 pfsense pf: 118.166.195.219.55362 > 114.43.203.127.21819: Flags [S], cksum 0xfb1c (correct), seq 86550498
Jun 5 12:59:59 pfsense pf: 00:00:00.592545 rule 1/0(match): block in on pppoe0: (tos 0x0, ttl 116, id 25902, offset 0, flags
Jun 5 12:59:59 pfsense pf: 124.11.64.120.64283 > 114.43.203.127.21819: Flags [S], cksum 0x0d0c (correct), seq 2623128094
Jun 5 13:00:00 pfsense pf: 00:00:01.364355 rule 1/0(match): block in on pppoe0: (tos 0x0, ttl 110, id 31094, offset 0, flags
Jun 5 13:00:00 pfsense pf: 122.96.58.54.39124 > 114.43.203.127.21819: UDP, length 23
Jun 5 13:00:02 pfsense pf: 00:00:01.560724 rule 1/0(match): block in on pppoe0: (tos 0x0, ttl 116, id 26057, offset 0, flags
Jun 5 13:00:02 pfsense pf: 124.11.64.120.64283 > 114.43.203.127.21819: Flags [S], cksum 0x0d0c (correct), seq 2623128094
我要把上一個個小時的LOG檔封存起來
麻煩指導
謝謝
--
Tags:
BBS
All Comments
Related Posts
freebsd可以以不用驅動直接支援讀卡機?
By Mason
at 2011-05-27T23:10
at 2011-05-27T23:10
無法解析名稱
By Noah
at 2011-05-24T21:57
at 2011-05-24T21:57
無法解析名稱
By Jack
at 2011-05-24T11:51
at 2011-05-24T11:51
無法解析名稱
By Kama
at 2011-05-23T20:43
at 2011-05-23T20:43
無法解析名稱
By Todd Johnson
at 2011-05-22T14:05
at 2011-05-22T14:05