我的问题是我无法运行功能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(){'