Using command substitution
, you can easily loop through the contents of a file. If the file will be more than one line, the only thing different you'll need to do is pipe the output of the file through tr
and replace all newlines with spaces.
This will only work, though, if your file does not contain words that have spaces in them.
for planet in `cat "$filename" | tr '\n' ' '`; do