I am passing a text file to a bash while running. Text file has contents I want to supply to a java program as argument. Text file has each content in a new line. The contents print fine within the loop but I need to create a concatenated string with all the contents to pass to java program and appending to a string variable in loop is not working. This is how the program looks like:
#!/bin/bash
args=""
for var in $(cat payments.txt)
do
echo "Line:$var"
args+="$var "
done
echo "$args"
It prints:
Line: str1
Line:str2
str2 // args should have appended values of each line but it got only last line
File looks like:
str1
str2
Can anyone suggests what I am doing wrong here?
Thanks