Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
Why not just grep for "foo" in the first place then? –  Ignacio Vazquez-Abrams Sep 5 '11 at 12:42
    
I want to check if a password contains any dictionary words. Thats why –  debtk Sep 5 '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 5 '11 at 13:22
    
@Alek Sood: you store your passwords in plaintext????!!!!! –  symcbean Sep 5 '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
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
I am using it to find if a password contains dictionary words. –  debtk Sep 5 '11 at 13:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.