Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 3
    You should consider using mapfile (or its synonym readarray) to construct the array directly from a process substitution - that way you can skip the string altogether. See for example (with find rather than du) bash: whitespace-safe procedural use of find into select Commented Aug 6, 2017 at 14:03
  • Thanks! I've modified it to: IFS= mapfile -t bigstuff < <(du -k / 2> /dev/null | sort -n | tail -n 10) and it's working perfectly. Commented Aug 6, 2017 at 14:24
  • 3
    To print the array with newlines, do: printf "%s\n" "${bigstuff[@]}" Commented Aug 6, 2017 at 16:11