Windows 中的 Grep 和 Awk 表达式错误中的无效字符 [英] Grep and Awk in Windows Invalid Char in Expression Error

查看:20
本文介绍了Windows 中的 Grep 和 Awk 表达式错误中的无效字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 grep 和 awk 的新手 - 使用 Windows 7(我从 GnuWin 下载了适用于 Windows 的 grep 和 awk).

I am new to grep and awk - using Windows 7 (I downloaded grep and awk for windows from GnuWin).

我在运行此脚本时遇到问题:

I am have having trouble running this script:

grep -Fwf dictionary.txt frequency.txt | awk '{print $2 "," $1}'

我收到错误:

awk: '{打印
awk: ^ 表达式中的字符 ''' 无效

I get the error:

awk: '{print
awk: ^ invalid char ''' in expression

我相信这可能与必须在 Windows 中使用双引号有关,但我尝试了所有我能想到的组合,但仍然不起作用.

I believe it might have something to do with having to use double quotes in Windows, but I tried all the combinations I can think of and still it doesn't work.

有人可以帮忙吗?谢谢

推荐答案

转义命令行项在 Windows 上总是很痛苦.作为最后的手段,您可能可以使用 gawk -f!

Escaping command line items is always a pain on Windows. As a last resort you could probably use gawk -f!

所以:您的文件 script.awk 包含:

So: your file script.awk contains:

print $2,$1

然后你做 grep -Fwf dictionary.txt frequency.txt |awk -f 脚本.awk

这篇关于Windows 中的 Grep 和 Awk 表达式错误中的无效字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆