shell script 抓關鍵字問題 - Linux

By Christine
at 2017-02-09T15:49
at 2017-02-09T15:49
Table of Contents
小弟想透過shell script抓kernel log中的一些關鍵字
像是下面一小串kernel log
<6>[ 2731.456308] xxx_handler_work -- wdg_val:0
<6>[ 2731.461548] xxx_do_hotword_work -- send hotword uevent!
<7>[ 2731.471493] cpu-tegra: force EDP limit 2014500 kHz
<4>[ 2734.430346] xxx_dsp_core_reset_put(684)dsp core reset:0
我用的shell script語法是
result =`dmesg | grep -c wdg_val`
理論上透過$result應該可以得到 1 這個數字
但是系統卻回應我
watchdog_test.sh[24]: result: not found
watchdog_test.sh[24]: [: 1: unexpected operator/operand
我是不是漏了什麼?
請教各位大大, 麻煩各位了, thanks
--
像是下面一小串kernel log
<6>[ 2731.456308] xxx_handler_work -- wdg_val:0
<6>[ 2731.461548] xxx_do_hotword_work -- send hotword uevent!
<7>[ 2731.471493] cpu-tegra: force EDP limit 2014500 kHz
<4>[ 2734.430346] xxx_dsp_core_reset_put(684)dsp core reset:0
我用的shell script語法是
result =`dmesg | grep -c wdg_val`
理論上透過$result應該可以得到 1 這個數字
但是系統卻回應我
watchdog_test.sh[24]: result: not found
watchdog_test.sh[24]: [: 1: unexpected operator/operand
我是不是漏了什麼?
請教各位大大, 麻煩各位了, thanks
--
Tags:
Linux
All Comments

By Irma
at 2017-02-11T00:32
at 2017-02-11T00:32

By Edith
at 2017-02-14T08:20
at 2017-02-14T08:20

By Eden
at 2017-02-19T01:12
at 2017-02-19T01:12
Related Posts
數值排列

By Belly
at 2017-02-09T15:02
at 2017-02-09T15:02
新手請教

By Kama
at 2017-02-09T13:39
at 2017-02-09T13:39
關於rsyslog收到訊息後被自動補字

By Hedwig
at 2017-02-08T09:48
at 2017-02-08T09:48
Trac + Git 管理多重專案

By David
at 2017-02-08T01:36
at 2017-02-08T01:36
fedora install xrdp

By Ivy
at 2017-02-06T23:33
at 2017-02-06T23:33