bash going through output line by line code example
Example 1: bash print output to one line
# Basic syntax:
<command_producing_multi-line output> | tr '\n' ' '
# Where:
# - | sends (pipes) the multi-line output of your command to tr
# - tr '\n' ' ' translates all new line characters from the multi-line
# output to spaces, resulting in all output on a single line.
# Note, change ' ' to whatever delimiter you want between the lines now
# displayed on a single line (e.g. ',' or ';' or '|')
Example 2: for line in output bash
Use for in bash for iterating words in a string or values in an array as:
for value in {1, 2, 3}; do echo $value; done
for value in $(cat arguments_files.txt); do [some_command]; done
And use while for iterating lines from a pipe output as:
cat arguments_file.txt | while read line; do [some_command]; done