加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 将字符串发送到stdin

发布时间:2020-12-15 16:50:20 所属栏目:安全 来源:网络整理
导读:有没有办法在bash中有效地做到这一点: /my/bash/script echo 'This string will be sent to stdin.' 我知道,我可以管道输出从回声,如: echo 'This string will be piped to stdin.' | /my/bash/script 您可以使用单行heredoc cat "This is coming from t
有没有办法在bash中有效地做到这一点:
/my/bash/script < echo 'This string will be sent to stdin.'

我知道,我可以管道输出从回声,如:

echo 'This string will be piped to stdin.' | /my/bash/script
您可以使用单行heredoc
cat <<< "This is coming from the stdin"

以上是一样的

cat <<EOF
This is coming from the stdin
EOF

或者您可以从命令重定向输出,如

diff <(ls /bin) <(ls /usr/bin)

或者你可以读为

while read line
do
   echo =$line=
done < some_file

或简单

echo something | read param

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读