${(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.

Examples

Split string with newlines into fields
1
2
3
4
# contains \n
value="$(ls -1)"
# each line contained in $value is split into a field
echo "Contents: ${(f)value}"
Output:
1
Contents: temp file1.txt file2.txt
BashSupport Pro ist eine Zsh IDE mit Unterstützung für ${(f)…} - probieren Sie es jetzt aus!
© 2020–2024 Joachim Ansorg
Impressum
Datenschutz
Rechtliches