Search code examples
windowscommand-promptfindstr

What is wrong wit this FINDSTR command on microsoft windows 10 enterprise machine


trying to get this work for the past hour, but couldn't see what is wrong.

FINDSTR /M /C:"260255" productattributes_20190413_000001.775.txt>Err.txt

string 260255 is available in the file productattributes_20190413_000001.775.txt and I am executing this command from the directory where this file is present. Err.txt is empty after executing this command.

full command -

C:\Users\nmangal\Desktop\feed_for_prod\price\attributes>FINDSTR /M /C:"260255" productattributes_20190413_000001.775.txt>Err.txt

Solution

  • I suspect your file is in UTF-16, in which case findstr will not find the text, because of the intervening nulls.

    Hence, one solution would be to convert the file to UTF-8.

    I am not aware of any way to make findstr handle UTF-16. In fact, Wikipedia says,

    However, while the find command supports UTF-16, findstr does not.

    So a different solution might be to use find instead.