Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
代码忽略bash中的if/else语句_Bash_Shell - Fatal编程技术网

代码忽略bash中的if/else语句

代码忽略bash中的if/else语句,bash,shell,Bash,Shell,我不知道你是否能帮我。。。我对以下代码有问题: #!/bin/bash if [ $# = 0 ]; then awk '{for (x=5; x<=NF; x++) {printf "%s ", $x } printf "\n" }' affy.txt else columns="" for i in $@; do if [ $i = "-g" ]; then word=$2 is_there_g=

我不知道你是否能帮我。。。我对以下代码有问题:

#!/bin/bash

if [ $# = 0 ]; then
    awk '{for (x=5; x<=NF; x++) {printf "%s ", $x } printf "\n" }' affy.txt
else
    columns=""
    for i in $@; do
        if [ $i = "-g" ]; then
            word=$2
            is_there_g="True"
            break
        else
            is_there_g="False"
        fi
        columns+="$i,"
        shift
    done
    columns=${columns%,}
    if [ $is_there_g="False" ]; then
        cat affy.txt | cut -d" " -f$columns 
    else
        grep $word affy.txt | cut -d" " -f$columns
    fi
fi

echo $is_there_g
#/bin/bash
如果[$#=0];然后

awk'{for(x=5;x运算符周围需要空格:

if [ $is_there_g = "False" ]; then

或获取更多信息。

您需要在操作员周围留出空间:

if [ $is_there_g = "False" ]; then

或获取更多信息。

您需要在操作员周围留出空间:

if [ $is_there_g = "False" ]; then

或获取更多信息。

您需要在操作员周围留出空间:

if [ $is_there_g = "False" ]; then

或了解更多信息。

@user2886545:如果这解决了您的问题,您应该通过单击绿色复选标记来接受。@user2886545:如果这解决了您的问题,您应该通过单击绿色复选标记来接受。@user2886545:如果这解决了您的问题,您应该通过单击绿色复选标记来接受。@user2886545:如果这解决了您的问题如果您遇到问题,请单击绿色复选标记接受。