开发者

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

How can I write the | (L开发者_开发问答inux) 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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜