file2 diff file1 file2 最佳答案 您不能使用两个 heres-6ren">
gpt4 book ai didi

bash - 在此处使用两个字符串

转载 作者:行者123 更新时间:2023-11-29 09:09:09 24 4
gpt4 key购买 nike

我可以使用 herestrings 将字符串传递给命令,例如

cat <<< "This is a string"

如何使用 herestrings 将 两个 字符串传递给命令?我怎样才能做类似的事情

### not working
diff <<< "string1" "string2"

### working but overkill
echo "string1" > file1
echo "string2" > file2
diff file1 file2

最佳答案

您不能使用两个 herestrings 作为同一命令的输入。实际上,最新的一个将取代所有其他的。示范:

cat <<< "string 1" <<< "string 2" <<< "string 3"
# only shows "string 3"

另一方面,如果你真的想要区分两个直接输入,你可以这样做:

diff <(echo "string 1") <(echo "string 2")

关于bash - 在此处使用两个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19904460/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com