bash - 使用 heredoc 重定向命令输出

标签 bash heredoc zenity

我有这样的命令:

sftp user@host <<EOF
put file.txt
exit
EOF

现在我想将它的输出通过管道传输到 zenity --progress,但我找不到放置它的地方。

# SFTP doesn't work anymore
sftp user@host | zenity --progress <<EOF
put file.txt
exit
EOF

# Invalid syntax, no end of heredoc
sftp user@host <<EOF
put file.txt
exit
EOF | zenity --progress

# Not picked as part of the command
sftp user@host <<EOF
put file.txt
exit
EOF
| zenity --progress

# Does not help
sftp user@host | zenity --progress <<EOF
put file.txt
exit
EOF\
| zenity --progress 

最佳答案

这应该可以解决问题:

sftp user@host <<EOF | zenity --progress
...
EOF

关于bash - 使用 heredoc 重定向命令输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10894554/

相关文章:

linux - 将文件附加到 tar 时如何删除旧文件

可自行编辑的 Bash 脚本

python - 如何在 Python heredocs 中插入变量?

PHP eval 和 heredoc 不能很好地发挥作用

bash - 将 zenity 的输出分配给变量

linux - 在文件中搜索文本字符串并替换它

bash - 通过 shell 脚本对文件进行唯一命名

python - python : source conda activate didn't work on Mac OS