我在Windows 10下运行Windows 10
我试图使用Gnu Bash运行以下sed一行:
sed -f <(sed -E 's_(.+)\t(.+)_s/\1/\2/g_' C:/dictionary.txt) C:/content.txtfile substitute sed语句将字典项转换为sed表达式。main sed将它们用于内容替换。
这是用How to awk to read a dictionary and replace words in a file?描述的
dictionary.txt看起来是这样的:
aluminium<tab>aluminum
analyse<tab>analyze
white spirit<tab>mineral spirits
stag night<tab>bachelor party
savoury<tab>savory
potato crisp<tab>potato chip
mashed potato<tab>mashed potatoescontent.txt看起来是这样的:
The container of white spirit was made of aluminium.
We will use an aromatic method to analyse properties of white spirit.
No one drank white spirit at stag night.
Many people think that a potato crisp is savoury, but some would rather eat mashed potato.
...
more sentences在windows 10下在GnuBash中运行GnuWin32 32/sed时,我收到以下错误消息:syntax error near unexpected token <(s
如何重新制定在windows 10?下GnuWin32 32/sed下运行的脚本
感谢https://stackoverflow.com/users/2836621/mark-setchell和https://stackoverflow.com/users/5403468/tiw,该解决方案在使用cygwin64时起作用
发布于 2019-03-01 16:09:31
一种方法是先将内部sed输出写入临时文件,然后使用它,然后删除它:
sed -r "s_(.+)\t(.+)_s/\1/\2/g_" C:/dictionary.txt>tmp_script.sed
sed -f tmp_script.sed C:/content.txt
del tmp_script.sed另一种方式是,根据马克·塞切尔的评论,加上一些小改动,cygwin 安装了。
这个工作既适用于bash,也适用于批处理:
sed -r "s_(.+)\t(.+)_s/\1/\2/g_" C:/dictionary.txt | sed -f /dev/stdin C:/content.txthttps://stackoverflow.com/questions/54947345
复制相似问题