0

Goal

I want to take a line break separated file (path in $2), check the path exists and add it to folderList.

Current Code

I am not yet checking for file path correctness as I can't get concatenation to work.

folderList=""

cat $2 | while read line
do
   folderList="$folderList;$line"
   echo $line #echos the right content
done

echo $folderList

The output shoes that it echos line correctly but folderList is simply an empty line (not showing on Stack Overflow formatting).

foo
bar

Working Code Without File Path Checking

folderList="$(tr '\n' ';' < $2)"
4

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.