Search code examples
linuxgreppipedosls

Converting the command 'ls | grep x' from linux to DOS


Would it be possible / how do you do the Linux command

ls | grep x

Using Windows DOS?


Solution

  • It seem that only way to do that in DOS is to use dir + find. Latter only accepts filename (no pipes allowed), so you will need a termporary file:

    dir > A:\list.txt
    find "CD" A:\list.txt
    

    It is also has very limited capabilities comparing with grep.

    Windows has more powerful tool findstr:

    dir | findstr CD