As part of my security job, I analyze dozens of Google Chrome history files each day using sqlite3 over SSH.
There are a few dozen authorized "safe" sites each user is allowed to navigate to. For my purposes, I don't care about these safe sites. To list the URLs of each history file and ignore the safe websites, I use grep -v and list each safe site as follows:
sqlite3 /home/me/HistoryDatabaseFile.db "select * from urls order by url;" | grep -v safesite1.com | grep -v safesite2.com | grep -v safesite3.com | grep -v safesite4.com
and on and on. My command has grown to at least 20 lines and is becoming unmanageable. Is there any way I could show the user's list of URLs while excluding my safe sites in a listed format? I'm imagining something like:
safesite1.com
safesite2.com
safesite3.com
and then bringing that list into the command. It can be internal or external- I don't really care as long as it ends up outputting in bash.
Thanks for any help you can give me!
inputfileis the input file, that you would like togrep. In your question you get the input from thesqlite3command, so you don't need it.grep -vf /home/me/safesites.txtshould work, though. What's the content of/home/me/safesites.txt? – pfnuesel Feb 02 '16 at 01:00-For--fixed-strings),.will match any single character - potentially letting through nefarious sites of the formsafesite2Xcom.com- and unless you enforce a whole-word or whole-line match, things likeunsafesite2.com– steeldriver Feb 02 '16 at 01:06