大家帮忙看看 是哪里出错了。。。

tsar7117
大家帮忙看看 是哪里出错了。。。

大家帮忙看看 是哪里出错了。。。
#!/bin/bash
while true
        do
                read -n1 key
                if [ "$key" = b || "$key" = B || "$key" = ^M || "$key" =  ^H ]
                then
                        free -m | awk '{print $3}' | >> free.txt;
                else
                        continue
                fi
        done

tsar7117
这是 错误提示
a./aa.sh: line 5: [: missing `]'
./aa.sh: line 5: a: command not found
./aa.sh: line 5: a: command not found
./aa.sh: line 5: a: command not found
b./aa.sh: line 5: [: missing `]'
./aa.sh: line 5: b: command not found
./aa.sh: line 5: b: command not found
./aa.sh: line 5: b: command not found
B./aa.sh: line 5: [: missing `]'
./aa.sh: line 5: B: command not found
./aa.sh: line 5: B: command not found
./aa.sh: line 5: B: command not found

walkerxk
if [color=Red][[[/color] "$key" = b || "$key" = B || "$key" = ^M || "$key" =  ^H [color=Red]]][/color]
[]只用在数字比较上。

tsar7117
谢~

tsar7117
但是我想要的效果还是没出来。。  
是这样的 这个脚本想监控键盘 如果输入的按键有 “b”,“B”,“backspace”,"enter" 就执行free -m这个命令
难道是前面的判断条件不对?

tsar7117
。。。。。。。。。。。

MYSQLER
[code]free -m | awk '{print $3}' | >> free.txt;[/code]

改为:

[code]free -m | awk '{print $3}' >> free.txt[/code]

walkerxk
free -m | awk '{print $3}' [color=Red]| [/color]>> free.txt;
把这个管道去掉。

tsar7117
哦  非常谢

walkerxk
纠正一个语法错误:echo ‘哦  非常谢’|sed 's//(.../)$//1/1/'

tsar7117
。。。。。。。。。。

sway2004009
if [ "$key" = b -o "$key" = B -o "$key" = ^M -o "$key" =  ^H ]