Last active
December 27, 2015 01:29
-
-
Save schnell18/7245427 to your computer and use it in GitHub Desktop.
find 8-digit named SQLite databases under current directory and run SQL and redirect the result to individual files. The gist demonstrates the use of regex in find command.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for db in $(find . -regextype posix-extended -regex '.*\<[0-9]{8}$' | cut -d'/' -f2-) | |
do | |
cat << EOF | sqlite3 $db > $db.dates | |
select distinct date(login_time, 'unixepoch') login | |
from login_record | |
; | |
EOF | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The [0-9] is used instead of \d because \d is not supported by find. The -regextype posix-extended is also required as the repetition modified {8} is an extended feature which is enabled by default.