https://wp.jochen.hayek.name/blog-en/2015/01/06/shell-scripting-for-i-in-or-while-read/
shell scripting: "for i in $( … )" or "… | while read" ?