#!/bin/sh
if [ $# -ne 8 ]; then
echo "Usage: sh `basename $0` YYYYMMDD hour min masterid account destination filename forward|backward";
exit 1;
fi
day=${1}
hour=${2}
min=${3}
masterid=${4}
account=${5}
destination=${6}
file=${7}
if [ "${8}" == "backward" ]; then
backward="true";
fi
if [ "${backward}" != "true" ]; then
awk -v day=${day} -v hour=${hour} -v min=${min} -v masterid=${masterid} -v account=${account} -v destination=${destination} -f /var/tmp/selfCross.awk /koba/c/dumper/${file}
else
tac "/koba/c/dumper/${file}" | awk -v day=${day} -v hour=${hour} -v min=${min} -v masterid=${masterid} -v account=${account} -v destination=${destination} -f /var/tmp/selfCross.awk
fi
如果向后!= true,则工作正常。但是,tac 不知何故不起作用,我该怎么办?它立即返回。我在上面的脚本中做错了什么?
答案1
不是答案,而是提示:使用“true”和“false”命令而不是测试字符串相等性:
backwards=false
if [[ some condition ]]; then backwards=true; fi
if $backwards; then
do something
else
do something else
fi