obelix obelix - 18 days ago 5
Linux Question

new line character in bash

I am currently writing a bash scipt where i need to concatenate the results within the output variable. However I need them to be seperated by newline charcater '\n' which does not seem to work... Any ideas ???

#!/bin/bash

for i in "./"*
do

#echo "$i"
tmp=$('/home/x.....s/eclipseWorkspace/groundtruthPointExtractor/Debug/groundtruthPointExtractor' "./"$i)
#echo $Output
#printf "$i $Output\n">> output.txt
Output=$Output$(printf $'\n %s %s' "$i" "$tmp" )
done
echo $Output
echo $Output> output.txt

Answer

Well looks like

echo "$str" works

because when you print the string without quotes, newline are converted to spaces !!!