Answers for "return in shell script"

1

return in shell script

#!/bin/bash
# Variables
name="GrePPeR"
out=""

##################################################################
# Purpose: Converts a string to lower case
# Arguments:
#   $@ -> String to convert to lower case
##################################################################
function to_lower() 
{
    local str="$@"
    local output
    output=$(tr '[A-Z]' '[a-z]'<<<"${str}")
    echo $output #equal to return
}

# invoke the to_lower()
to_lower "This Is a TEST"

# invoke to_lower() and store its result to $out variable
out=$(to_lower ${name})

# Display  back the result from $out
echo "Domain name : $out"
Posted by: Guest on August-28-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language