-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

5
  • Why not just grep for "foo" in the first place then? Sep 5, 2011 at 12:42
  • I want to check if a password contains any dictionary words. Thats why
    – debtk
    Sep 5, 2011 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 Sep 5, 2011 at 13:22
  • @Alek Sood: you store your passwords in plaintext????!!!!!
    – symcbean
    Sep 5, 2011 at 14:13
  • @symncbean haha...No dude! whats stored in plain text is a list of passwords not allowed
    – debtk
    Oct 25, 2011 at 15:41

1 Answer 1

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.

1
  • I am using it to find if a password contains dictionary words.
    – debtk
    Sep 5, 2011 at 13:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .