无法在脚本中运行功能

我的问题是我无法运行功能order_sessions()...

我已经知道我是否有别名,但没有。我正在运行更新的MacOS,但是我已经在Linux中尝试过...

#!/bin/bash

path="/var/log/wtmp"

file_array=() 

function read_file(){
    while IFS= read -r line; do 
    file_array+=("$line")
    done < "$path"  
}
read_file()

function order_sessions(){
    case $2 in

    -r)
        statements ;;
    -n )
        statements ;;
    -t )
        statements ;;
    -a )
        statements ;;
    -i )
        statements ;;

esac
}


case $1 in

      )
      if [![ -z "$2" ]]
      then
      fi
        statements ;;
    -g )
        statements ;;
    -u )
        statements ;;
    -s )
        statements ;;
    -e )
        statements ;;
    -f )

        path = $2
        read_file() ;;
esac

终端给我这个错误:

./userstats.sh: line 18: syntax error near unexpected token `function'
./userstats.sh: line 18: `function order_sessions(){'
mm00ll 回答:无法在脚本中运行功能

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3124752.html

大家都在问