Thursday, June 5, 2014

'or'-ing terms with bash and grep

Needing to search for lines in a group of files having either of the supplied terms.

grep -e foo -e bar *.txt
With a more complete context:

  for file in $(ls aaa.txt bbb.txt)
  do
    echo ""
    echo $file
    echo "======================="
    cat $file | grep -e "^foo" -e "^bar"
  done
http://unix.stackexchange.com/questions/37313/how-do-i-grep-for-multiple-patterns

removing app from launchpad

Accidentally dragged an app onto Launchpad instead of the Applications directory.  Needed to remove it and found this:

http://osxdaily.com/2012/01/05/remove-apps-from-launchpad/

... but I had problems running the snippet as it was.  I ended up running something like this:


sqlite3 "/Users/john/Library/Application Support/Dock/1426ED5E-E2B5-43CF-9616-698ED687577D.db" "DELETE from apps WHERE title='SomeApp';" && killall Dock

Apparently, I had to provide a full path to the sqlite3 database.  Running 'ls' pulled up not one, but two entries.  The command to sqlite3 only takes a single database file.