gpt4 book ai didi

linux - 如何在 Linux shell 脚本中将多个字符串转换为单个字符串

转载 作者:太空宇宙 更新时间:2023-11-04 03:37:06 25 4
gpt4 key购买 nike

我有一个像(“50342364232,Munish 鼓舞人心”)这样的字符串,但是当我将此作为输入时,它在 linux shell 中作为 3 个字符串,那么如何将其作为单个字符串?我输入了类似 ./filename“50342364232,Munish 鼓舞人心的”

最佳答案

如果您调用像 ./program "50342364232 , Munish Innovative" 这样的程序,包括引号,那么它将被解释为 program 的单个参数。但是,如果在 program 中执行类似 call other-program $1 的操作,那么当 $1 展开时,它将展开为多个参数。要解决这个问题,您需要将其作为 other-program "$1" 调用,这会将其保留为单个参数。

关于linux - 如何在 Linux shell 脚本中将多个字符串转换为单个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31176232/

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