Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嘿伙计们,我想将一个字符串分成两个单独的字符串,例如分辨率=1024x786 到宽度=1024 和高度=786。为此,我发现了该代码:
set -- "$resolution" IFS="x"; declare -a coordinates=($*)
来源 但现在我的所有变量都包含在任何位置拆分的“x”。如何仅将这个“IFS”用于我的 $ 分辨率?
感谢您的帮助 :)
一种解决方案
IFS=x read -r -a coordinates <<<"$resolution"
如果您实际上想要单独变量中的值:
IFS=x read -r width height <<<"$resolution"