Guest User

Untitled

a guest
Mar 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #! /bin/bash
  2. set -e
  3. set -u
  4.  
  5. # redis-cli --raw FLUSHALL >/dev/null 2>%1; # uncomment to clear the database
  6.  
  7. function hash () {
  8. printf %s "$1" | md5sum | cut -f1 -d' '
  9. }
  10.  
  11. # file 1
  12. cat "$1" | while read -r line; do
  13. hash $line | { read hash; redis-cli --raw SET $hash 1 >/dev/null 2>&1; }
  14. done
  15.  
  16. # file 2
  17. cat "$2" | while read -r line; do
  18. RESULT=$(hash $line | { read hash; redis-cli --raw GET $hash; })
  19.  
  20. if [[ -z "$RESULT" ]]; then
  21. printf "%s\n" "$line"
  22. fi
  23. done
  24.  
  25. # redis-cli --raw FLUSHALL >/dev/null 2>%1; # uncomment to clear the database
Add Comment
Please, Sign In to add comment