Reputation: 85
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_
Upvotes: 3
Views: 2694
Reputation: 85
I got it.
DIRS=/folder/log
export DIRS
ls -d */ | grep -v errlogs | parallel --env DIRS readfile_
Upvotes: 2