nevios
nevios

Reputation: 63

How can I write the pipe command Linux in Windows batch?

How can I write the | (Linux) command in a Windows cmd (batch file)?

I don't know how to write this little Linux script in Windows:

find -r * |grep *.fd | open

In Windows:

dir /S ???  open

Upvotes: 0

Views: 1529

Answers (2)

Joey
Joey

Reputation: 354744

I don't really know what open does. If it simply starts an associated application with the respective file, then the following should do it:

for /r %f in (*.fd) do (start "" "%f")

In PowerShell you can do the same with:

Get-ChildItem -Recurse -Filter *.fd | Invoke-Item

or shorter:

gci -rec -fi *.fd | ii

Upvotes: 2

sharmaprateek
sharmaprateek

Reputation: 80

The regular command shell in windows is lacking in power and features. However, Windows Power Shell has the ability to run a lot of ninja commands similar to *nix shells.

You can get more information about power shell on MSDN - http://msdn.microsoft.com/en-us/library/aa973757%28v=vs.85%29.aspx

Here is an example I googled from Powershell help itself:

-------------------------- EXAMPLE 4 --------------------------

C:\PS>get-childitem c:\windows\system32* -include *.txt -recurse | select-string -pattern "Microsoft" -casesensitive

This command examines all files in the subdirectories of C:\Windows\System32 with the .txt file extension, for the string "Microsoft". The CaseSensitive parameter indicates that the 'M' in 'Microsoft' must be capitalized and the rest of the characters must be lowercase for a match to occur.

Upvotes: 0

Related Questions