0
filenname="/home/sxxxx/lob.oaxxx"
while read a b 
do
    mdate=$(date -d "$b" +'%s')
    system_todate=$(date +'%s')
    ((diff=$system_todate-$mdate))
    days=`echo "$diff/86400" | bc`
    echo "$(date +%Y-%m-%d) $a $b $days"
$mysql -e "insert into dataStagDatabase.dataStagTable (as_on_date, hdfs_location, last_modified, no_of_days) values (STR_TO_DATE('$(date +%Y-%m-%d)','%Y-%m-%d'), '$a', STR_TO_DATE('$b', '%Y-%m-%d' )", '$days');" -u root  
done < "$filenname"

I get the following error, I tried modifying insert statements in various ways, but couldn't succeed. Kindly help

oaisys_datastag.sh: line 19: syntax error near unexpected token `)'
oaisys_datastag.sh: line 19: `mysql -e "insert into dataStagDatabase.dataStagTable (as_on_date, hdfs_location, last_modified, no_of_days) values (STR_TO_DATE($(date +%Y-%m-%d),'%Y-%m-%d'), $a, STR_TO_DATE($b, '%Y-%m-%d' )", $days);" -u root  '
3
  • 1
    On your second to last line, you have one opening " and two closing ". Make your quotes consistent, and pair them up appropriately. Commented May 17, 2016 at 16:30
  • extra " : STR_TO_DATE('$b', '%Y-%m-%d' )" Commented May 17, 2016 at 18:19
  • are you aware that in shell script variable value will be treated as string if single quoted. I am seeing you are using ' : '$b'. Check it out x=Haddop : echo "$x" vs echo '$x' Commented May 17, 2016 at 18:22

1 Answer 1

1

On your second to last line, you have one opening " and two closing ". Make your quotes consistent, and pair them up appropriately. – Paul L

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.