${(f)…}
: Split at newlines
(f)
splits the expanded result at newlines (\n
).
${(f)name}
is equivalent to ${(ps:\n:)name}
.
(F)
is performing the reverse: it’s joining elements of arrays into a single string with \n
.
Links
Examples
- Split string with newlines into fields
- Output:
1 2 3 4
# contains \n value="$(ls -1)" # each line contained in $value is split into a field echo "Contents: ${(f)value}"
1
Contents: temp file1.txt file2.txt
BashSupport Pro 是一款支持 f** 的 **Zsh 集成开发环境 - 立即试用!