运行使用ssh远程awk命令 [英] Run a remote awk command using ssh

查看:117
本文介绍了运行使用ssh远程awk命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试运行使用ssh远程awk的声明。我的code是:

I try to run a remote awk statement using ssh. My code is:

ssh username@hostIP "awk 'NR==1  {max=0;min=1} NR>1 {if (max<\$3) max=\$3}END {print max}' FS=\",\" /path_to_my_file"

当我运行此命令时,我收到任何错误消息,但命令不工作,不产生输出,但只是挂所以我需要通过CTRL + C取消它。

When I run this command, I receive no error message, but command is not working and doesn't produce an output but just hanging so I would need to cancel it by ctrl+c.

有我丢失的东西?

推荐答案

试试这个使用的这里-DOC 的:

ssh -t username@hostIP <<'EOF'
awk '
    NR==1 {max=0;min=1}
    NR>1 {if (max<$3) max=3}
    END {print max}
' FS="," /path_to_my_file
EOF

围绕 EOF prevent shell扩展的单引号。

The single quotes around EOF prevent shell expansion.

这篇关于运行使用ssh远程awk命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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