我有一个 bash 脚本
counter=0
for file in /home/ec2-user/Workspace/events_parts/*
do
counter=$[counter + 1]
event=$(cat $file | jq '.Event')
echo $event
if [ "$event" = "Time Exceeded" ] || [ "$event" = "Load Time" ]; then
echo "Coming Here"
jq ".url = \"$(jq '.Message' $file | sed 's/.*proxy=\([^&]*\).*/\1/')\"" $file
else
jq ".url = null"
fi
done
~
在上面的 bash 脚本中,我试图Event
从 JSON 文件中提取字段并检查两个可能的值。if [ "$event" = "Time Exceeded" ] || [ "$event" = "Load Time" ];
不像我期望的那样工作。我已经验证了我正在比较的值确实存在。