Indent String

Add indentation to each line of a string.

Code

General
indent=$(printf '%*s' "$spaces" '')
echo -e "$s" | sed "s/^/$indent/"

Parameters

Multi-line string

Number of spaces to indent

Server

More Bash Snippets