#!/bin/bash { echo "This line will be only printed once!" padded=$(printf '%*s' $(sed -e 's/^[[:space:]]*//' "$0" | wc -c) ' ' | cat - "$0") echo "$padded" > "$0" exit 0 }