Find text in file a, not in file b

word=$(</tmp/dev.txt)

for i in $word; do
  grep -qF "$i" /tmp/ver.txt
  if [ $? -eq 1 ] ; then
    echo "$i"
  fi
done
  • Oneliner

for i in $(</tmp/dev.txt); do grep -qF "$i" /tmp/ver.txt || echo "$i"; done
  • $(</tmp/dev.txt) reads each word from the file

  • grep -qF "$i" searches quietly (exact match)

  • || echo "$i" prints the word if it's not found in /tmp/ver.txt

Last updated