obelix obelix - 1 year ago 98
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 ???


for i in "./"*

#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" )
echo $Output
echo $Output> output.txt

Answer Source

Well looks like

echo "$str" works

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download