在 Windows 中使用 grep、sed、awk 的外壳
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7866512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Shell with grep, sed, awk in windows
提问by James
Recently started work at a place that uses windows exclusively, and really could do with a simple shell that replicates bash functionality. MinGw and Cygwin seem overkill for what I need. Any suggestions gladly accepted. Thanks
最近开始在一个专门使用 windows 的地方工作,并且真的可以用一个简单的 shell 来复制 bash 功能。MinGw 和 Cygwin 似乎对我需要的东西来说太过分了。很乐意接受任何建议。谢谢
回答by paxdiablo
You don't have to install allof Cygwin, since you can select individual packages.
您不必安装所有Cygwin,因为您可以选择单个软件包。
Having said that, I still prefer to install the lot simply because I would rather have all the tools handy when I need them, rather than having to go and figure out which packages they're in. Even if you install the lot, no-ones forcing you to useall of them and, let's face it, disk space is hideously inexpensive nowadays.
话虽如此,我仍然更喜欢安装批次,因为我宁愿在需要时将所有工具都放在手边,而不必去弄清楚它们在哪些软件包中。即使您安装了批次,也不会-那些强迫你使用所有这些的,让我们面对现实吧,现在磁盘空间非常便宜。
If you want individual binaries for things like grep
, sed
and awk
, you can also look into GnuWin32- these are native executables that don't require the Cygwin DLL. You can just choose the executables you want from the package list and they'll be installed for you.
如果您需要单独的二进制文件,例如grep
,sed
和awk
,您还可以查看GnuWin32- 这些是不需要 Cygwin DLL 的本机可执行文件。您只需从软件包列表中选择您想要的可执行文件,它们就会为您安装。
回答by Idan Arye
A shell's functionality usually uses external programs. You can download the windows versions of the tools you want: grep, awk, sed
shell 的功能通常使用外部程序。您可以下载所需工具的 Windows 版本: grep、awk、sed
You might also want to take a look into PowerShell- a windows shell that is actually good(much, much, much better than CMD), and has good interaction with the Windows environment.
您可能还想看看PowerShell——一个实际上很好的 Windows shell(比 CMD 好得多),并且与 Windows 环境具有良好的交互。
回答by mousio
Not exactly a shell, but I still use tools from the UnxUtils package, one of many tool sets which has ported little lightweight commands/apps/tools, ever so handy and useful in scripts.
Nowadays I am also exploring Powershellmore and more, a shell certainly worth taking a look at. On Wikipedia's Powershell pageone can even find a comparison of cmdlets with similar commands in Bash a.o., which you might find interesting.
不完全是一个 shell,但我仍然使用UnxUtils 包中的工具,这是许多移植了轻量级命令/应用程序/工具的工具集之一,在脚本中非常方便和有用。
现在我也在越来越多地探索Powershell,一个绝对值得一看的 shell。在Wikipedia 的 Powershell 页面上,您甚至可以找到cmdlet 与 Bash ao 中类似命令的比较,您可能会觉得这很有趣。