字串比較問題求救 - Linux

By Connor
at 2016-08-17T21:45
at 2016-08-17T21:45
Table of Contents
版上大大大家好
小弟最近正在學習Linux中,但遇到了一個數值比對問題無法解決,懇請版上大大指點迷
津
game()
{
if [ -n 'echo ${_game_list} | grep -i " PO"' ]; then _game_id =POKEMON
if
if [ -n 'echo ${_game_list} | grep -i " HG"' ]; then _game_id =HGAME
if
}
我在_game_list 中,輸入的是GOODPOK,原本預設會出來是POKEMON,但結果是HGAME。
但如果把
if [ -n 'echo ${_game_list} | grep -i " HG"' ]; then _game_id =HGAME
if
去掉,值就是POKEMON,請問大大,是否有參數設定錯誤,導致判斷總是以後式決定呢?
還請不吝指點,萬分感謝!
--
小弟最近正在學習Linux中,但遇到了一個數值比對問題無法解決,懇請版上大大指點迷
津
game()
{
if [ -n 'echo ${_game_list} | grep -i " PO"' ]; then _game_id =POKEMON
if
if [ -n 'echo ${_game_list} | grep -i " HG"' ]; then _game_id =HGAME
if
}
我在_game_list 中,輸入的是GOODPOK,原本預設會出來是POKEMON,但結果是HGAME。
但如果把
if [ -n 'echo ${_game_list} | grep -i " HG"' ]; then _game_id =HGAME
if
去掉,值就是POKEMON,請問大大,是否有參數設定錯誤,導致判斷總是以後式決定呢?
還請不吝指點,萬分感謝!
--
Tags:
Linux
All Comments

By Ophelia
at 2016-08-19T09:35
at 2016-08-19T09:35

By Andrew
at 2016-08-19T12:02
at 2016-08-19T12:02

By Lydia
at 2016-08-20T13:47
at 2016-08-20T13:47

By Andrew
at 2016-08-24T16:50
at 2016-08-24T16:50

By Todd Johnson
at 2016-08-29T07:22
at 2016-08-29T07:22

By Gary
at 2016-09-03T06:35
at 2016-09-03T06:35

By Oliver
at 2016-09-04T02:10
at 2016-09-04T02:10

By Candice
at 2016-09-05T18:02
at 2016-09-05T18:02

By Zora
at 2016-09-08T12:01
at 2016-09-08T12:01
Related Posts
win7連samba 顯示該IP拒絕連線

By Donna
at 2016-08-17T16:02
at 2016-08-17T16:02
有沒有像ease partition的工具?

By Kama
at 2016-08-17T07:12
at 2016-08-17T07:12
求助Raspberry Pi3

By Eartha
at 2016-08-17T02:19
at 2016-08-17T02:19
Linux架設mail server收過的信重複一直來

By Eden
at 2016-08-16T19:55
at 2016-08-16T19:55
有關舊linux硬體支援的查詢

By Hardy
at 2016-08-16T07:33
at 2016-08-16T07:33