find file names that return success on -exec command
bash, find, linux, unix
Solution
You just need to `-print` after the `-exec`. It is a short circuiting boolean `and`, and by putting `-print` before `-exec`, the print happens before the exec does.
find . -name sqlite.db -exec ... \; -print
Problem
I am using find to find names of databases that return some rows for a query. ``` $ find . -name 'sqlite.db' -exec sqlite3 "{}" 'SELECT * FROM table WHERE column1="value"' \; value|a|b|c|d ``` But I want the name of the database, so I tried -print which showed all the names ``` $ find . -name 'sqlite.db' -print -exec sqlite3 "{}" 'SELECT * FROM table WHERE column1="value"' \; /dir1/a/sqlite.db value|a|b|c|d /dir2/a/sqlite.db /dir2/b/sqlite.db /dir3/a/sqlite.db ``` Is there a way I can get only the files where the exit status of the command run is success.