Dos command to search a string in a file




















Windows operating systems provide the tool named find to search text files for a given term or string. Linux also have a command with the same name but it is used to search files and folders names not file contents. Windows find command is very simple and easy command to work. Syntax of the find command provides options , string to search and file or drive or path to be searched. We will simple made a search in files. We will do not provide any option.

Given term will be search in given file , path or drive. As we can see we provided the search term or string in double quotes to prevents errors and misuses. While searching terms the default behaviour is case sensitive. Case sensitive means all provided string upper and lower cases are searched according to their cases and no case change will be made. We can change this behaviour according to our needs and search terms in case sensitive so given search term will match all cases accordingly.

In previous example we have provided single term to search. In some situations we may need to search multiple terms. We can provide multiple strings to findstr command to search. All given strings will be like OR. In this example we will search terms ismail , john. Regular expressions are used to specify the structure of the string not the whole characters of the string. We can express a string start and end characters. As seen in the output below, the only file containing "hope" is the CH.

TXT file. TXT CH. Tip If you're running Windows XP or later, consider using the improved findstr command. Availability Find syntax Find examples.



0コメント

  • 1000 / 1000