// Personal website of Chris Smith

Snippets » zsh » Split data on newlines

zsh has a nice shortcut for splitting data on newlines, instead of ugly read/IFS hacks, by using the f parameter expansion flag, e.g.:

for i in "${(f)$(ls -l)}"; do
  echo "$i";
done