Arrays “文件”<<<&引用;在bash shell中
在bsd unix、bash shell中可以执行以下操作:Arrays “文件”<<<&引用;在bash shell中,arrays,bash,shell,variables,Arrays,Bash,Shell,Variables,在bsd unix、bash shell中可以执行以下操作: stuff=$(echo "dog cat rat") read -r -a astuff <<< "$stuff" for file in "${astuff[@]}"; do echo "file=$file"; done stuff=$(回声“狗猫老鼠”) read-r-aastuff这里称为字符串。你可以阅读 这里是字符串 此处文件的一个变体,格式为: [n]<<<
stuff=$(echo "dog cat rat")
read -r -a astuff <<< "$stuff"
for file in "${astuff[@]}"; do echo "file=$file"; done
stuff=$(回声“狗猫老鼠”)
read-r-aastuff这里称为字符串。你可以阅读
这里是字符串
此处文件的一个变体,格式为:
[n]<<<word
The word undergoes brace expansion, tilde expansion, parameter and
variable expansion, command substitution, arithmetic expansion, and
quote removal. Pathname expansion and word splitting are not
performed. The result is supplied as a single string, with a newline
appended, to the command on its standard input (or file descriptor n
if n is specified).
[n]您可以搜索manbash
以获取解释。这是一种可能的方法:
$ man bash | grep -A10 -B4 "<<<"
还有3行,它们是不相关的
您可以重复搜索其他单词和您不理解的“单词”。中
read -r -a astuff <<< "$stuff"
read-r-astuff是read
将字符串围绕空格(更准确地说,围绕$IFS的字符)进行拆分。是另一个很好的字符串资源。可能也有帮助,而且作业是经典的。更直接的解释链接:。请不要链接到ABS。它充满了错误和坏习惯。这里有一个链接到@马卡。菲茨杰拉德……如果你想要一些比ABS更正式的链接,比官方文档更不正式,你也可以考虑,或者(这里的页面靠近页面底部)。ABS是w3schools的shell脚本——因传播不良做法和过时信息而臭名昭著。很好的直接链接,@chepner,感谢您对ABS质量的关注。@CharlesDuffy:很好地类比了w3schools:ABS-很好知道。
read -r -a astuff <<< "$stuff"
read -r -a astuff <<EOF
$stuff
EOF