len no Bash
len no Bash
Script Bash para retornar o tamanho de uma string, muito útil para uso rápido no terminal.
#!/bin/bash
# Description: Get the length of a string
# Usage: len <string>
# Example: len "hello world"
# Output: 11
set -euo pipefail
[ "$#" -ne 1 ] && { echo "Usage: len <string>" >&2; exit 1; }
printf '%d\n' "${#1}"