简体   繁体   English

如何在Cygwin中正确传送命令(使用Windows)?

[英]How to correctly pipe commands in Cygwin (Using Windows)?

I'm trying to run experiments on a text file to get word frequencies. 我正在尝试对文本文件进行实验以获取单词频率。 I tried using the following command: 我尝试使用以下命令:

gawk -F"[ ,'\".]" -v RS="" '{for(i=1;i<=NF;i++) words[$i]++;}END{for (i in words) print words[i]" "i}' myfile.txt | uniq -c | sort -nr | head  -10

But I get the following error: 但是我收到以下错误:

gawk: cmd. line:1: fatal: cannot open file '|' for reading (No such file or directory)

I read somewhere that ';' 我在某处读到“;” may be used instead of '|' 可以代替“ |” on Windows machines, although this results in a similar error. 在Windows计算机上,尽管这会导致类似的错误。

It seems as though it is reading the first instance of '|' 似乎正在读取“ |”的第一个实例 as a file name. 作为文件名。 Is this the correct way of piping on a windows machine? 这是在Windows机器上进行配管的正确方法吗? Is piping possible on a windows machine using Cygwin? 使用Cygwin是否可以在Windows机器上进行管道输送?

EDIT: I added cygwin to windows PATH variable and then used cmd window. 编辑:我将cygwin添加到Windows PATH变量,然后使用cmd窗口。 If i wanted to actually use cygwin.exe, does that mean I would have to place any files I wanted to edit within C:/cygwin ? 如果我想实际使用cygwin.exe,是否表示我必须将要编辑的所有文件放在C:/ cygwin中?

OK, now I understand - don't do that! 好,现在我明白了-别那样! Execute cygwin commands from cygwin, not from Windows. 从cygwin而不是Windows执行cygwin命令。 To execute a cygwin command on any file, just give the command the full path to the file (but starting with /cygdrive/ ), it doesn't have to be under C:/cygwin , eg from a cygwin shell window to see what's in the common Windows folder C:\\Documents and Settings : 要在任何文件上执行cygwin命令,只需为命令提供文件的完整路径(但以/cygdrive/开头),它不必位于C:/cygwin ,例如从cygwin shell窗口中查看内容在常见的Windows文件夹C:\\Documents and Settings

$ ls -Q '/cygdrive/c/Documents and Settings'
"All Users"  "Default"  "Default User"  "desktop.ini"  "emorton" etc...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM