2
是否有一個在Bash中縮進字符串(用於輸出)的示例? 我發現使用printf
的例子,但他們似乎沒有按預期工作。 我想簡單地用給定數量的空格縮進給定的字符串。如何使用printf在Bash中縮進字符串?
echo "Header"
indent "Item 1" 2
indent "Sub Item 1a" 4
indent "Sub Item 1b" 4
會產生輸出
Header
Item 1
Sub Item 1a
Sub Item 1b
必須添加換行符在那裏'printf的 「%$ {} num_spaces s%S \ n」' – IntrovertedRoot