get_person_details() {
local name="John"
local age=25
# Return the values
echo "$name $age"
}
# Extract the values from the func
read -r name age <<< "$(get_person_details)"
echo "Name: $name"
echo "Age: $age"
# output:
Name: John
Age: 25
Last active
October 24, 2024 10:47
-
-
Save ariesmcrae/fb2e6d0d95120c7a31c6a42b5a8995ab to your computer and use it in GitHub Desktop.
Bash v5 scripting: Method returns multiple values
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment