How can i make a newline in a for loop in bash? I've tried echo -e
but its not working. When i am opening a log file everything is on a single line.
for i in */ ; do
sitefolder="$HOME/domains/${i%%/}/public_html"
if [ -d "$sitefolder" ]; then
echo -e "\nBackup of ${i%%/} successfull" >> $logs/backups.log
fi
done
What am i doing wrong? Thanks
Best Answer
In the line:
echo -e "\nBackup of ${i%%/} successfull" >> $logs/backups.log
Replace the Newline (
\n
) with a Carriage Return + Newline (\r\n
) to ensure that both are happening.For more info, perhaps check out this Programmers.stackexchange.com question: Difference between '\n' and '\r\n', and this StackOverflow question: Historical reason behind different line ending at different platforms