Abhishake Yadav Abhishake Yadav - 1 year ago 109
Bash Question

using sqlite3 in for loop in shell script gives error

Need to query a certain value from each file in a directory and put it in a file. I use the code:


ls -lrt | grep -w "458752" | awk '{print $9}' | sort -V > list

for linename in cat list

/d/home/alima0152/Desktop/sqlite3 $linename "select trace_count from volume"; >> trc_count


rm list

But I get this error:

file is encrypted or is not a database

Answer Source

This code is trying to open the files cat and list.

To execute something and insert its output, use `...` or $(...):

for linename in $(cat list)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download