• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Tips and Tricks HQ

  • Home
  • Projects
    • All Projects
    • Simple WP Shopping Cart
    • WP Express Checkout Plugin
    • Accept Stripe Payments
    • WP Download Monitor
    • Easy HTTPS Redirection
    • WP Security and Firewall Plugin
    • WP eStore Plugin
    • WP Affiliate Platform
    • WP eMember
  • Products
    • All Products
    • Checkout
  • Support
    • Support Portal
    • Customer Only Forum
    • WP eStore Documentation
    • WP Affiliate Software Documentation
    • WP eMember Documentation
  • Contact

Equivalent of UNIX Grep command in Dos/Windows

Home » Blog » Equivalent of UNIX Grep command in Dos/Windows

Last updated: May 22, 2010





You can use the ‘type’ and ‘find’ command in Dos/Windows to get the equivalent output of the UNIX ‘cat’ and ‘grep’ commands. The ‘find’ command can be very useful when you are trying to search for a specific text or phrase over multiple files. The ‘find’ command also comes in handy when searching for all the occurrences of a specific text or phrase in all the files under all the sub-directories of a given directory.

The Type Command

The ‘type’ command in Dos simply displays the contents of a text file or files. To see the content of a file simply enter the following in the command prompt:
C:>type “filename”

The Find Command

The ‘find’ command in Dos can be used to search for a text string in a file or files. below is the usage and optional parameters of the ‘find’ command.

FIND [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]

/V         Displays all lines NOT containing the specified string.
/C         Displays only the count of lines containing the string.
/N         Displays line numbers with the displayed lines.
/I         Ignores the case of characters when searching for the string.
/OFF[LINE] Do not skip files with offline attribute set.
"string"   Specifies the text string to find.
[drive:][path]filename
Specifies a file or files to search.

If a path is not specified, FIND searches the text typed at the prompt or piped from another command.

Find Command Usage Examples

To find any text occurrence in all the files within a directory simply enter the following at the command prompt.



C:>find “text to find” *


D:\Project Material\find command example>find "text-align" *

---------- ADSENSE INSERTION TAG.TXT
<p style="text-align: center;"><!-- wp_ad_camp_1 --></p>
---------- CFORMS.PHP
echo '<p style="text-align: left;"><label for="cforms-title'.$no.'">';
---------- ROBOTS.TXT
---------- ROBOTS_LANGUAGE_FILTER.TXT
---------- TRANSLATION_PAGE.TXT

Use the ‘/n’ parameter to print out the line numbers.


D:\Project Material\find command example>find /n "text-align" *

---------- ADSENSE INSERTION TAG.TXT
[1]<p style="text-align: center;"><!-- wp_ad_camp_1 --></p>
[2]text-align
[3]Test line with the text text-align
[6]Another line with the desired text text-align

---------- CFORMS.PHP
[2269]          echo '<p style="text-align: left;"><label for="cforms-title'.$no.'">';

---------- ROBOTS.TXT

You can use ‘type’ and then pipe the output to the ‘find’ command:

D:\Project Material\find command example>type robots.txt | find /n "Disallow: /iw/"
[37]Disallow: /iw/

You can get really creative with these commands.

Related Posts

  • List of useful and frequently used DOS Commands
  • Minimize the start up time of your Windows computer
  • Basic UNIX Commands List
  • UNIX vi commands – take advantage of the UNIX vi editor

Tech Tips dos command,  UNIX,  Windows

Reader Interactions

Comments (10 responses)

  1. dutado says:
    August 5, 2012 at 4:34 pm

    You may also use just grep. It was not bundled with DOS, but you can get it. For example from Borland Pascal distribution (but not for free).

  2. Vikas says:
    July 27, 2012 at 7:20 pm

    You can also try the “dir” command to find files in general.

  3. kiran says:
    May 31, 2012 at 4:17 pm

    Well done ..I was searching for this ..It helped me

  4. Daniel Brockman says:
    July 11, 2011 at 12:17 pm

    It’s nice to know about FIND, and @G.R. FINDSTR. I wonder how old are these DOS commands. I also wonder why MSFT couldn’t simply use the gnu grep. In absence of better information, I’ll suppose MSFT has a chronic profound affliction of “not-invented-here” syndrome.

  5. Ganesh says:
    May 11, 2011 at 3:17 am

    very nice post and valuable one for the developers who is working in xml file mostly. great post.. well done.. keep posting.

    thanks for your valuable post.

  6. G.R. says:
    March 4, 2011 at 7:25 pm

    Why you didn’t use FINDSTR command instead of FIND?

  7. Carlo says:
    November 8, 2010 at 6:32 am

    Hi, thank you for sharing this handy piece of information!

  8. Icechen1 says:
    August 21, 2010 at 4:04 pm

    Hehe, thanks for the share! As a old unix user, this can come in handy! Bookmarked.

  9. Danish says:
    August 5, 2010 at 4:25 pm

    Thank you for sharing the info.
    Indeed Find is grep like but alas not grep

    with grep, tr, cut it seems. If only Mic had given a little bit of attention to another side of the user interface- one as powerful as the command line. It would have the support of majority of the programmers.

  10. Cindy z says:
    July 2, 2010 at 10:13 am

    THANKS for sharing! I used to use grep and cat on unix which came in very handy. now the find and type commands will be very handy as well. THANKS!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Featured & Popular Articles

Video Answers to Top WordPress QuestionsWordPress Optimization Tips and Tricks for Better Performance and SpeedEssential WordPress Security Tips - Is Your Blog Protected?WordPress Simple PayPal Shopping Cart PluginTop 15 Search Engine Optimization (SEO) Techniques I Forget to DoList of the Best and Must Use WordPress PluginsHow do I Start a Blog and Make Money Online?Good Domain Name Picking Tips for Your Blog SetupFind Out Which WordPress Web Hosting Company Offers the Cheapest and Reliable Web Hosting Solution

Featured WordPress Plugins

WP Express Checkout Plugin
wordpress estore plugin
wordpress membership plugin
wordpress affiliate plugin

Recent Posts

  • How to Use Browser Developer Tools to Inspect Elements and [...]
  • Accept Donations via PayPal from Your WordPress Site Easil [...]
  • Buy Now Button Graphics for eCommerce Websites [...]
  • Subscription Button Graphics for eCommerce Websites [...]
  • Adding PayPal Payment Buttons to Your WordPress Sidebar Ea [...]

Comment & Socialize

  • @Rob, We have just released ...
    - admin
  • I installed the plugin a co ...
    - Rob
  • @Sebastian, We've released ...
    - admin
  • I've used this plugin on a ...
    - Sebastian Djupsjöbacka
  • @John, this plugin doesn't ...
    - admin

Check out our solutions

View our WordPress plugin collection and start using them on your site.

Our WordPress Solutions

Footer

Company

  • About
  • Privacy Policy
  • Terms and Conditions
  • Affiliate Login

Top WordPress Plugins

  • Simple Shopping Cart
  • PayPal Donations
  • WP Express Checkout
  • WP eStore
  • WP eMember

Blogging Tips

  • How to Start a Blog
  • Selecting a Good Domain
  • Cheap WP Hosting
  • WP Video Tutorials
  • Simple SEO Tips

Search


Keep In Touch

Copyright © 2025 | Tips and Tricks HQ