Toute ligne contenant plus de 7 caractères contient également une sous-chaîne de 7 caractères (qui correspondra à votre expression).
Vous pouvez forcer uniquement les correspondances complètes en ancrage l'expression au début et à la fin de la ligne :
grep '^[a-zA-Z0-9]\{7\}$' /usr/share/wordlists/rockyou.txt
ou spécifier une correspondance sur toute la ligne à l'aide de l'option -x
option
grep -x '[a-zA-Z0-9]\{7\}' /usr/share/wordlists/rockyou.txt
En man grep
:
-x, --line-regexp
Select only those matches that exactly match the whole line.
For a regular expression pattern, this is like parenthesizing
the pattern and then surrounding it with ^ and $.