在 Windows 下使用 linux 实用程序的最佳方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3519738/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:32:58  来源:igfitidea点击:

What is the best way to use linux utilities under windows?

windowslinuxcygwin

提问by Eastern Monk

Linux utilities like sed, awk and other shell scripting features are awesome and life becomes a lot harder when I am developing on windows and cant use any of these.

像 sed、awk 和其他 shell 脚本功能这样的 Linux 实用程序非常棒,当我在 Windows 上开发并且无法使用其中任何一个时,生活变得更加困难。

People suggest to use cygwin for those who want the linux like tools under windows. But I feel cygwin will be an overkill for someone who only wants to use the handful commands.

人们建议将 cygwin 用于那些想要在 windows 下使用类似 linux 工具的人。但我觉得 cygwin 对于只想使用少数命令的人来说是一种矫枉过正。

Some say that Windows Services for Unix can also be a good alternative.

有人说 Unix 的 Windows 服务也可以是一个不错的选择。

I have used none of these. Can some experienced programmer suggest best/simplest way to do this? of course apart from switching to linux itself.

这些我都没有用过。一些有经验的程序员可以建议最好/最简单的方法来做到这一点吗?当然,除了切换到 linux 本身。

采纳答案by Mizipzor

I think the GnuWin32project is exactly what you're looking for. Unix command line tools ported to Windows.

我认为GnuWin32项目正是您正在寻找的。Unix 命令行工具移植到 Windows。

回答by Richard Harrison

I've been using UnxUtilswhich are ports of common GNU utilities to native Win32 for ages.

多年来,我一直在使用UnxUtils,它们是常见的 GNU 实用程序到本地 Win32 的端口。

I should add that I've also used Cygwin (et al.) and Microsoft's Services for Unix and neither of them were any good for mebecause they don't work as well as native versions from the command prompt, and using ksh/bash/whatever under Windows never really works right, even though I use ksh under unix all the time.

我应该补充一点,我还使用了 Cygwin(等人)和 Microsoft 的 Unix 服务,但它们对我都没有任何好处因为它们在命令提示符下的运行效果不如本机版本,并且使用 ksh/bash /whatever 在 Windows 下永远不会真正正常工作,即使我一直在 unix 下使用 ksh。

回答by polemon

I tried something like this quite often, but to be honest, none of it really works well.

我经常尝试这样的事情,但老实说,没有一个真正有效。

I therefore suggest using a virtual machine (such as VirtualBox) and install a small linux inside that. You can easily move files from and to the guest system with shared folders.

因此,我建议使用虚拟机(例如VirtualBox)并在其中安装一个小型 linux。您可以使用共享文件夹轻松地将文件移入和移出来宾系统。

Judging by my experience, it is the best solution I used so far.

从我的经验来看,这是我目前使用的最好的解决方案。

回答by Brian Rasmussen

There's a GNU port of many of the utils. I find that quite useful.

许多 utils都有一个GNU 端口。我觉得这很有用。

If you need Perl, I recommend Strawberry Perl.

如果你需要 Perl,我推荐Strawberry Perl。

回答by Alexis Dufrenoy

I tried Gowfor some time, and it's nice. It offers 130 Unix-shell utilities for Windows. The contextual menu in the File explorer, to start a prompt in the current folder, is really handy.

我试了一段时间Gow,它很好。它为 Windows 提供了 130 个 Unix-shell 实用程序。文件资源管理器中的上下文菜单用于在当前文件夹中启动提示,非常方便。

回答by legends2k

The problem with most of the tools suggested here is that they don't get updated very often E.g. the last update GnuWin32 got was on 27 December 2010; UnxUtils was last updated on 01 March 2007.

这里建议的大多数工具的问题是它们不会经常更新,例如 GnuWin32 的最后一次更新是在2010 年 12 月 27 日;UnxUtils 最后更新于2007 年 3 月 1 日

I suggest MSYS2, a very good option which has a Win32 port of Arch's pacmanpackage management system built-in. It's a spin-off from Cygwin like MSYS but much better than MSYS (lots of packages and gets updated almost daily) and (very light as opposed to) Cygwin.

我建议MSYS2,这是一个非常好的选择,它内置了Arch pacman包管理系统的 Win32 端口。它是 Cygwin 的衍生产品,类似于 MSYS,但比 MSYS(大量软件包并且几乎每天更新)和(与 Cygwin 相比非常轻巧)要好得多。

It's a rolling release distributionthat works under Windows and thus you get the latest and greatest of the packages. It also has another list of packages under the MinGW package list; MinGW provided here has both x86 and x86_64 flavours.

它是在 Windows 下运行的滚动发行版,因此您可以获得最新最好的软件包在 MinGW 包列表下还有另一个包列表;这里提供的 MinGW 有 x86 和 x86_64 两种风格。

The maintainers are also very affable.

维护人员也非常和蔼可亲。

回答by Bob Fanger

Install msysGit(netinstaller), it comes with a (msys/minGW) shell environment.

安装msysGit(netinstaller),它带有一个 (msys/minGW) shell 环境。

It also adds a "open shell here" in explorer.

它还在资源管理器中添加了一个“此处打开外壳”。

It's faster than Cygwin, but at the sacrifice of unix compatibility.

它比 Cygwin 快,但牺牲了 Unix 兼容性。

回答by Steve314

MSYS is a common alternative for people who find CygWin excessive. It's still a special prompt, but it was originally intended to set up just enough Unix-compatibility to build programs using the MinGW compilers and the typical configure/make routine.

对于发现 CygWin 过多的人来说,MSYS 是一种常见的替代方法。它仍然是一个特殊的提示,但它最初的目的是设置足够的 Unix 兼容性来使用 MinGW 编译器和典型的 configure/make 例程构建程序。

Using tools like sed and awk isn't going to work quite as expected in a normal Windows command prompt. It can be done to a point, but common usage involves command-line syntax that is normally interpreted by the shell, but which the Windows command prompt doesn't support. One example is wildcard file specifications. I've often found that Unix-centric tools aren't as usable on Windows as they assume the shell has expanded those wildcards into lists of files for them.

在正常的 Windows 命令提示符下,使用 sed 和 awk 之类的工具不会像预期的那样工作。它可以在一定程度上完成,但常见用法涉及通常由 shell 解释的命令行语法,但 Windows 命令提示符不支持该语法。一个例子是通配符文件规范。我经常发现以 Unix 为中心的工具在 Windows 上并不像它们假设 shell 已将这些通配符扩展为它们的文件列表那样可用。

回答by Zozo

Maybe it is stupid, but I usually search google for i.e.: "indent windows". You can select tools from mixed platforms. Lot of stuff from open systems has been ported on windows.

也许这很愚蠢,但我通常会在谷歌上搜索 ie:“缩进窗口”。您可以从混合平台中选择工具。许多来自开放系统的东西已经移植到 Windows 上。