Working shell/R sampling in parallel