rsync question

R Kimber richardkimber at btinternet.com
Mon Nov 3 14:30:53 UTC 2014


On Mon, 03 Nov 2014 09:09:07 +1100
Karl Auer wrote:

> On Sun, 2014-11-02 at 20:55 +0000, R Kimber wrote:
> > >    rsync .... 2>&1 | grep -v "ignoring unsafe symlink"
> > But if I do [ $? -ne 0 ] is it rsync or grep that returns the value?
> 
> Both return a value, but it is grep's that will be placed in $?. $?
> "expands to the exit status of the most recently executed foreground
> pipeline."
> 
> If you want to check rsync's return value instead (or as well) you will
> have to execute the two parts separately:
> 
> TEMPFILE=/tmp/$$
> rsync ... > $TEMPFILE 2>&1
> RSYNCVAL=$?
> grep ... $TEMPFILE > /dev/null 2>&1
> GREPVAL=$?
> rm $TEMPFILE
> (...do things with $RSYNCVAL and $GREPVAL...))

Many thanks 

- Richard
-- 
Richard Kimber





More information about the ubuntu-users mailing list