Reputation: 7260
I have a file test.sh in which i have a query which gives me the count of total records in the table, as shown below:
Query:
echo db2 -x "select count(*) from testable”
Now I want to assign the whatever value it returns after executing it to the variable as totalRecords
using the Unix Shell Script.
Upvotes: 0
Views: 3649
Reputation: 278
#!/bin/bash
cnt=`db2 -x "select count(*) from syscat.tables" `
echo "Counter is: ${cnt}"
Counter is: 474
Upvotes: 3