Modify string in bash to contain new line character?
<p>I am using a bash script to call google-api's upload_video.py (<a href="https://developers.google.com/youtube/v3/guides/uploading_a_video" rel="nofollow">https://developers.google.com/youtube/v3/guides/uploading_a_video</a> )</p>

<p>I have a mp4 called output.mp4 which I would like to upload.</p>

<p>The problem is I cannot get my array to work how I would like. </p>

<p>This new line character is "required" because my arguments to python script contain spaces. </p>

<p>Here is a simplified version of my bash script:</p>

<pre><code># Operator may change these
hold=100
location="Foo, Montana "
declare -a file_array=("unique_ID_0" "unique_ID_1")

upload_file=upload_file.txt
upload_movie=output.mp4

# Hit enter at end b/c \n not recognized
upload_title=$location' - '${file_array[0]}' - Hold '$hold' Sweeps 
'
upload_description='The spectrum recording was made in at '$location'.
'
# Overwrite with 1st call &gt; else apppend &gt;&gt;
echo "$upload_title" &gt; $upload_file
echo "$upload_description" &gt;&gt; $upload_file

# Load each line of text file into array
IFS=$'\n'
cmd_google=$(&lt;$upload_file) 
unset IFS

nn=1
for i in "${cmd_google[@]}"
do
    echo "$i"
    # Delete last character: \n 
    #i=${i[-nn]%?}
    #i=${i: : -nn}
    #i=${i::${#i}-nn}
    i=${i%?}
    #i=${i#"\n"}
    #i=${i%"\n"}
    echo "$i"
done

python upload_video.py --file=$upload_movie --title="${cmd_google[0]}" --description="${cmd_google[1]}"
</code></pre>

<p>At first I attempted to remove the new line character, but it appears that the enter or \n is not working how I would like, each line is not separate.  It writes the title and description as one line.   </p>

<p>How do I modify my bash script to recognize a newline character?</p>

<p>This is much simpler than you are making it.</p>

<pre><code># Operator may change these
hold=100
location="Foo, Montana"
declare -a file_array=("unique_ID_0" "unique_ID_1")

upload_file=upload_file.txt
upload_movie=output.mp4

upload_title="$location - ${file_array[0]} - Hold $hold Sweeps"
upload_description="The spectrum recording was made in at $location."

cat &lt;&lt;EOF &gt; "$upload_file"
$upload_title
$upload_description
EOF

# ...

readarray -t cmd_google &lt; "$upload_file"

python upload_video.py --file="$upload_movie" --title="${cmd_google[0]}" --description="${cmd_google[1]}"
</code></pre>

<p>I suspect the <code>readarray</code> command is all you are really looking for, since much of the above code is simply creating a file that I assume you are receiving already created.</p>

python bash google-api