I need to run a bash function for each element in a dir via gnu parallel. I need to access a evn variable for this function. how do I pass in it. for example following code in a shell script. I have a variable DIRS=/folder/log. how do I pass 'DIRS' to function readfile_ . thanks in advance.
export SHELL=$(type -p bash)
function readfile_ {do something}
export -f readfile_
ls -d */ | grep -v errlogs | parallel readfile_
I got it.
refer to http://www.gnu.org/software/parallel/parallel_tutorial.html#Transfer-environment-variables-and-functions
DIRS=/folder/log
export DIRS
ls -d */ | grep -v errlogs | parallel --env DIRS readfile_
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With