I am trying to run below mentioned script but it giving an error-:
last=`grep '[email protected]' test | sed 's/"//g'| awk 'BEGIN { FS = "," } ; { print $8 }' | awk 'BEGIN { FS = " " } ; { print $1 }' | grep $(date +%Y-%m-%d --date='1 days ago') | head -1`
d=`(date +%Y-%m-%d --date='3 days ago')`
echo $d--$last
if [ $d == $last ]
then
h=`grep '[email protected]' test | wc -l`
echo $h
fi
The format of file test is -:
"[email protected]","74","PR-460","Mob","one","i.3","2013-11-20 18:12:26","2013-11-21 11:55:33"
"[email protected]","74","PR-460","Mob","one","i.3","2013-11-20 18:12:26","2013-11-21 11:55:33"
"[email protected]","74","PR-460","Mob","one","i.3","2013-11-20 18:12:26","2013-11-21 11:55:33"
error-: line 4: [: 2013-11-20: integer expression expected
echoline displaying? Also, what shell are you using--bash?d=$(date ...). The parenthesis inside of the backticks do nothing but make your script less efficient (by creating, and then destroying, an extra subshell).echo "$d--$last". See mywiki.wooledge.org/BashPitfalls#echo_.24foo==isn't actually valid syntax inside of POSIX-standard shells; you should use a single=inside your tests unless you're explicitly writing for bash.