在Jupyter Notebook中使用管道进行Awk打印无法使用iPython [英] Awk print with pipes not working iPython in Jupyter Notebook
本文介绍了在Jupyter Notebook中使用管道进行Awk打印无法使用iPython的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,以下命令在使用iPython的Jupyter Notebook中没有任何输出:
So the command below does not give me any output in Jupyter Notebook with iPython:
IP = '62.172.72.131'
!cat hits.csv | grep {IP} | awk '{print $1}'
我已经尝试了双号和单号"$",但都没有用.如果我在命令中仅使用一个管道,则可以正常工作.例如:
I have tried both double and single "$" sign and none of them works. If I only use one pipe in the command, it works fine. For example:
IP = '62.172.72.131'
!cat hits.csv | grep {IP}
!cat hits.csv | awk '{print $1}'
有人知道为什么会这样吗? 谢谢!
Anyone know why this is happening? Thanks!
推荐答案
我想我明白了.在iPython中,"$","{"和}"都是特殊字符,因此我必须通过将它们加倍来对其进行转义.
I think I figured this out. The "$" and "{" and "}" are all special characters in iPython, so I have to escape them by doubling them.
IP = '62.172.72.131'
!cat hits.csv | grep {IP} | awk '{{print $$1}}'
这篇关于在Jupyter Notebook中使用管道进行Awk打印无法使用iPython的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文