Consider the script:
#!/bin/bash
fun() {
echo "hello $1"
}
echo "fun world" | parallel
Now, the function fun is not available in the script echoed by echo.
Is there a way to make it available / export it?
Edit: See GNU parallel
Consider the script:
#!/bin/bash
fun() {
echo "hello $1"
}
echo "fun world" | parallel
Now, the function fun is not available in the script echoed by echo.
Is there a way to make it available / export it?
Edit: See GNU parallel
You have the function name inside quotes, the correct syntax is:
echo $(fun world) | parallel
The output from the echo ("hello world") will be passed to parallel through the pipe, so it will be up it it to do something with it.
EDIT:
I might have misunderstood. If you want a script called parallel to execute the function then there are a few issues. If bash then you need to export it as @CharlesDuffy said:
export -f fun
but beware that not all shells support exported functions, so be sure that parallel is a bash script.