我有一个列表:
$aws events list-rules | awk '{print$6" " $7}'
ENABLED
ENABLED
7 11
1 11
7 11
7 11
4 11
6 11
上面的列表:4 11
的意思是:4 Nov
我想比较一下该列表和当前时间:$date
Nov 7
我已经尝试过了,但仅是一日比较: 我的bash脚本:
!/bin/bash
x=`aws events list-rules |grep "transaction*" | awk '{print$6}'`
for i in $x
do
used=$( date | awk '{print$3}' )
if [ $i -lt $used ]
then
echo $i;
fi
done
但是我不知道如何隐瞒Nov
到-> 11
进行比较,但只比较天,也比较月。
请帮助我,bash或python。
更新:
#!/bin/bash
x=`aws events list-rules | awk '{print$7" " $6}'`
for i in $x
do
used=$( date +"%m %d" )
if [ $i -lt $used ]
then
echo $i;
fi
done
但是错误:
./test.sh: line 6: [: too many arguments
./test.sh: line 6: [: too many arguments
./test.sh: line 6: [: too many arguments
./test.sh: line 6: [: too many arguments