Windows Command Line (CMD)

Cyberkur Syiem 20 Reputation points
2023-05-25T10:23:11.8+00:00

I have a project which i have to search all the files: C\Users\Documents\Flag.txt. from this location just using the cmd command. but the files flag.txt are more than 30-40 files along with the sub-files. Among these 30 files and sub-files there is only one file with the text or flag inside, the rest are empty. How will i find the one with the text inside with just a cmd? can you suggest a command or filter to dso that?

Windows for business Windows Client for IT Pros Devices and deployment Configure application groups
Windows for business Windows Server User experience PowerShell
Windows for business Windows Server Devices and deployment Configure application groups
Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2023-05-25T13:14:25.5766667+00:00

    II'm not sure that I correctly understand your question, but I think that what you are asing is: The file C\Users\Documents\Flag.txt contains some text. You wish to search some folder and it's subfolders for files that contain this text.

    You can do that with findstr.

    findstr /g:C\Users\Documents\Flag.txt /s C:\TheTopFolderThatYouWantToSearch\*
    

    If you would only want to search .txt files, you would do it like this.

    findstr /g:C\Users\Documents\Flag.txt /s C:\TheTopFolderThatYouWantToSearch\*.txt
    

    https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/findstr

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.