Reputation: 11
I am very new to scripts, but I am writing a little rsync script for my NAS. I am now trying to edit the output of the rsync "stats" parameter.
Because this parameter give a lot of details, and I only need the final results, I start by only keeping the part I want :
sed -e '/Number/,$!d' $log > tmp && mv tmp $log
So that output for now looks like this :
So then I would like to remove the kind of timestamp from each line :
sed -e 's,.*] ,,' $log > tmp && mv tmp $log
So now it looks like this (in Outlook, as I send this result by email) :
So then, I thought I could add a new line. I have tried multiples possibilities, but it doesn't work the way I would like. I can't show you a 3rd picture though.
Would you have any suggestion for me :) ? Thanks for your help !
Upvotes: 0
Views: 343
Reputation: 11
Thanks Lars for your answer. Your code did what I wanted, but the problem persisted.
Lucky me, I found my problem with outlook : https://naveensnayak.wordpress.com/2012/08/30/ms-outlook-messing-up-line-breaks/
So instead of adding a new line, I made a very little change to my code :
sed -e 's,.*], ,' $log > tmp && mv tmp $log
Because there is a whitespace after my bracket (]), and that I add a 2nd whitespace, now my file looks nice in Outlook.
Upvotes: 1
Reputation: 10189
You can add a newline to a file with the echo command:
> cat test.txt
1
2
3 > echo -e "\n" >> test.txt
> cat test.txt
1
2
3
>
-e
enables the backslash interpretation"\n"
is interpreted as newline>>
appends instead of overwritesUpvotes: 0