0

我正在尝试创建一个简单的 bash 脚本来从 CURL 获取 HTTP 代码

所以这是我的代码:

#!/bin/bash
AWKRESULT = $(curl -sL -w "result=%{http_code}" "http://192.168.8.69:8080/myReport/archive" -o "/tmp/reportlog" | awk -F= '{print $2}')
echo $AWKRESULT

的结果

curl -sL -w "result=%{http_code}" "http://192.168.8.69:8080/myReport/archive" -o "/tmp/reportlog" | awk -F= '{print $2}'

是 500。

然而它总是有这个结果:

./test.sh[2]:AWKRESULT:未找到。

知道我错过了什么吗?

4

1 回答 1

2

删除周围的空格=

AWKRESULT=$(...)
于 2012-07-17T11:13:17.403 回答