I'm using | sed to indent the result of some command (let's take a plain $ echo something for this example). I want to prefix the result with, say, 10 spaces. The following works fine:
$ echo something | sed 's/^/ /' something But isn't there a way to use quantifiers in the | sed expression?
I tried for example
$ echo something | sed 's/^/ {10}/' {10}something But obviously it doesn't work. {10} isn't interpreted as a quantifier.
And protecting the braces with backslashes doesn't work either:
$ echo something | sed 's/^/ \{10\}/' {10}something Is there a way to use quantifiers in the substitution expression?
| awk '{printf "%10s%s\n", "", $0}'. Know you are asking for sed, so only a comment.awkwhen I think "string replacement", but it seemsawkcan sometimes be more convenient thansed. Thanksprintfin general is a powerful tool for formatting. Have a look into it if not familiar with it. It differs some between implementations, i.e. shells, coreutils, c, awk, perl, ... but basics are the same. E.g. also:awk -v width=10 '{printf "%*s%s\n", width, "", $0}'(using asterisk in format string to denote width is a variable).expandcommand:echo 'something' | sed 's/^/\t/' | expand -it 10