I am trying to assign the result of the db2 command to a variable inside a shell script:
backup_end_time="$(db2 select END_TIME FROM SYSIBMADM.DB_HISTORY where operation = "'B'" AND OBJECTTYPE = "'D'" ORDER BY START_TIME DESC FETCH FIRST 1 ROWS ONLY | awk 'NR==4')"
echo $backup_end_time
When I echo I am getting a blank value. I am expecting value 20191113030053.
If I try the same command outside the script without assigning to variable
db2 select END_TIME FROM SYSIBMADM.DB_HISTORY where operation = "'B'" AND OBJECTTYPE = "'D'" ORDER BY START_TIME DESC FETCH FIRST 1 ROWS ONLY | awk 'NR==4'
I get the expected output.
How can I assign the output to a variable?