File Searching and Viewing CMD

Here are some essential Command Prompt (CMD) commands for searching and viewing files in Windows:


### **1. **Searching for Files**


- **`dir [filename] /s`**: Searches for files by name in the current directory and all subdirectories.

  - **Example:** `dir file.txt /s`


- **`where [filename]`**: Locates files by name within directories listed in the PATH environment variable.

  - **Example:** `where file.txt`


### **2. **Viewing File Contents**


- **`type [file]`**: Displays the contents of a file.

  - **Example:** `type file.txt`


- **`more [file]`**: Shows file contents one page at a time.

  - **Example:** `more largefile.txt`


### **3. **Finding Text Within Files**


- **`find "text" [file]`**: Searches for a specific text string within a file.

  - **Example:** `find "error" logfile.txt`


- **`findstr "text" [file]`**: Searches for text within files, supports regular expressions.

  - **Example:** `findstr "error" logfile.txt`


### **4. **Displaying Directory Contents**


- **`dir`**: Lists files and folders in the current directory.

  - **Example:** `dir`


- **`dir /b`**: Lists file and directory names in bare format, without extra information.

  - **Example:** `dir /b`


- **`dir /s`**: Lists files and folders in the current directory and all subdirectories.

  - **Example:** `dir /s`


These commands help you efficiently search for files and view their contents from the Command Prompt.