-1

I know on the file A, has a string that contains dc034 however, i cannot get that with grep command either using the word count or by searching for the string. What am i doing wrong? Suggestions

 grep "dc034" filedirectoryA | wc
    0       0       0

grep -Fv "dc034" filedirectoryA
Community
  • 1
  • 1
user5987994
  • 9
  • 1
  • 10
  • Can't really guess. From what you've typed, it looks like the file doesn't have the string in question. Perhaps the string is not really there but it's some non-ascii character that looks similar to the characters you typed. What is the file? – Noufal Ibrahim Jul 25 '17 at 06:28
  • related: 1. [for files](https://stackoverflow.com/questions/9439121/fuzzy-file-search-in-linux-console?s=1|2.1501) 2. [strings in file](https://stackoverflow.com/questions/30355972/fuzzy-string-matching-with-grep?noredirect=1&lq=1) – J. Chomel Jul 25 '17 at 06:44
  • Show some example data – hek2mgl Jul 25 '17 at 06:47
  • `grep -Fv` would grep lines not matching "dc034". Also is filedirectoryA a file or a directory.If its a directory, then try `grep "dc034" filedirectoryA/*` – Lohit Gupta Jul 25 '17 at 06:48
  • If `grep "dc034" filedirectoryA` and `grep -v "dc034" filedirectoryA` both produce no output then your file is empty. – Ed Morton Jul 26 '17 at 04:07

2 Answers2

0

You cannot search for non-exact match with grep.

Only thing you could do is search case-insensitively:

grep -i "dc034" filedirectoryA

Or are you trying to do fuzzy search on Unix? agrep exists in some distros. githup agrep looks like a revived open source release. Might help too.

Failing that, see if you can find tre-agrep for your distro.

Hope this helps;

J. Chomel
  • 8,193
  • 15
  • 41
  • 69
0

You can enter asterisk(*) before and after the string and try to search.