When I execute unison tours 2> /dev/null | grep -A 2 '<-?->' on a bash prompt, I get the exact output i'm looking for:
*changed <-?-> changed Future Tours/File Clash Test.docx
local : changed file modified on 2013-06-05 at 16:24:40 size 10221 rw-rw----
bj-server... : changed file modified on 2013-06-05 at 16:23:53 size 10232 rw-rw----*
When I put this into a shell script:
#!/bin/bash
tmp=$(unison tours 2> /dev/null | grep -A 2 '<-?->')
echo "$tmp" > /home/users/itsystem/test.log
... it comes out strange. Running more test.log , I get the following:
- Systems Sheets/Feedback She oup).xls | Past Tours/2012/CE0 12 Cherry (N...our Menus/Lijiang Tour Menus.xls - Past Tours/2012/UC041112 St - Past Tours/2012/UC081112 Lopata (N... Menus - UC081012 Lo 2/VC110912 Levin (VI... Menus - VC110912 Levin (VI).xlsx xlsx | Future Tours/2013 Futur / Inquiries/Outstanding/Terence Park... Itinerary (Trev changed changed Future Tours/File Clash Test.docx local : changed file modified on 2013-06-05 at 16:24:40 size 10221 rw-rw---- bj-server... : changed file modified on 2013-06-05 at 16:23:53 size 10232 rw-rw----
Where is the other crap coming from?
If you simply run unison then you do get an animated one line of output that is constantly refreshed with a rotating -\|/ showing the working folder, but which eventually disappears.
If my grep works on the bash prompt, why not from the shell script?