Windows Command Line (CMD)

Cyberkur Syiem 0 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 10 Security
Windows 10 Security
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
2,763 questions
Windows Server Security
Windows Server Security
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.Security: The precautions taken to guard against crime, attack, sabotage, espionage, or another threat.
1,730 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,253 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,383 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 32,071 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