Function Definition in Shell
Level 375 keystrokes
Defines a function greet that keeps its first argument in a local variable and prints a greeting, then calls it with "Developer".
Shell code
# Define a function named greet1greet() { # $1 is the first argument; local keeps name inside the function2 local name="$1" # Print the greeting: Hello, Developer!3 echo "Hello, $name!" # return sets the exit status (0 = success), not a value4 return 05}# Call the function like a command, passing "Developer" as $16greet "Developer"Output
Hello, Developer!
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Shell code and how often they appear.
"× 6$× 2,× 1!× 1(× 1)× 1{× 1}× 1=× 1