“read”在禁用伪终端分配模式下不起作用

“read”在禁用伪终端分配模式下不起作用

我需要执行一个单行bash,它读取 的输出ls,将输出存储到一个变量中,然后再对该变量执行如下操作:

ls <dir_that_has_just_one_file> | read filename && echo $filename

当我在主机上时,这工作得很好。但是,当我使用堡垒主机作为跳转主机时,它不起作用:

ssh -T <bastion_host> ssh <destination_host> "ls <dir_that_has_just_one_file> | read filename && echo $filename"

没有任何输出。

感谢是否有任何解决方法。谢谢你!

相关内容