-2

How Can I use grep so as to return me all matches for not only entire expression but also any part of the expression.

example:

grep "foobar" foo

where foo contains text foo should give me a match

debtk
  • 3
  • 2
  • Why not just grep for "foo" in the first place then? – Ignacio Vazquez-Abrams Sep 05 '11 at 12:42
  • I want to check if a password contains any dictionary words. Thats why – debtk Sep 05 '11 at 13:07
  • Your question still doesn't make sense, any part of 'foobar', includes f, fo, foo, foob, fooba, foobar, o, oo, oob, ooba, oobar, ob, oba, obar, b, ba, bar, a, ar. If you have a dictionary full of words and you're grepping with it, it's already working as required (fish will match fishing), if your dictionary doesn't contain all word variants (only has fishing and not fish) that's a different issue – EightBitTony Sep 05 '11 at 13:22
  • @Alek Sood: you store your passwords in plaintext????!!!!! – symcbean Sep 05 '11 at 14:13
  • @symncbean haha...No dude! whats stored in plain text is a list of passwords not allowed – debtk Oct 25 '11 at 15:41

1 Answers1

0

Why don't you simply grep on "foo". Without any flag, grep matches everything ; while the flag "-w or --word-regexp" does an exact matching.

Razique
  • 2,276
  • 1
  • 19
  • 23