i like the idea of doing a dry run first. and then using that output in a rm -i command
how's this for a one liner:
Code:
rm -ri `rsync -anv --delete $source/ $destination/ | grep deleting | sed 's/deleting /$destination/\/g'`
Okay, fiddled with the sed replacement. Need "" instead of '' to get the variable parsed,
and since it's possible file names have spaces, need (?) to quote them; leaving out the rm -i :
Code:
rsync --delete --dry-run --recursive --verbose $source/ $destination/ | grep deleting | sed "s:deleting :$destination/:g" | sed "s/\(^.*\)$/\'\1\'/g"
Okay, that gets me output on stdout like
'/home/alan/Documents/temp/dest/test (copy).txt'
and
Code:
rm -i '/home/alan/Documents/temp/dest/test (copy).txt'
works
But when I tuck rm -i in front of rsync etc:
Code:
rm -i `rsync --delete --dry-run --recursive --verbose $source/ $destination/ | grep deleting | sed "s:deleting :$destination/:g" | sed "s/\(^.*\)$/\'\1\'/g" `
somehow rm is getting the file names broken at white space ( it can't find files
/home/alan/Documents/temp/dest/test
(copy).txt
)
I tried wrapping file names in double quotes, same result.
Any ideas what I'm doing wrong?
Bookmarks