[Bash] function

Functions in Bash allow you to group commands into reusable blocks. This helps make your scripts more modular and easier to manage.

function_name() {
  commands
}

Example:

#!/bin/zsh

greet() {
  echo "Hello, $1!"
}

greet "Alice"
  • function_name() { commands }: Defines a function.
  • $1: Represents the first argument passed to the function.
posted @ 2024-05-23 03:09  Zhentiw  阅读(2)  评论(0编辑  收藏  举报