0

I have this example:

migrate(){
    case $1 in 
        "team_container")
            echo "Rodando Migrate de ${1}",

            ;;
        "evaluation_container")
            echo "Rodando Migrate de ${1}",

            ;;
        "school_container")
            echo "Rodando Migrate de ${1}",

            ;;
        "class_container")
            echo "Rodando Migrate de ${1}",

            ;;
        "student_container")
            echo "Rodando Migrate de ${1}",

            ;;
        "messages_container")
            echo "Rodando Migrate de ${1}",

            ;;
        "logs_container")
            echo "Rodando Migrate de ${1}",

            ;;
    esac
}
export MIGRATE=migrate;
docker ps  --format {{.Names}} | xargs bash -c "MIGRATE {}"

Output:

MIGRATE: command not found

xargs cannot find the function, even if exporting it and calling a subshell.

How can i pass my function migrate as parameter to xargs?

0

1 Answer 1

1

Pass it as argument:

xargs -n1 bash -c 'migrate "$1"' _

Remember to export your function:

export -f migrate
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.