Options (5)
-l, --listbooleanList unformatted files
Example:
shfmt {{[-l|--list]}} {{path/to/directory}}-w, --writebooleanWrite the result to the file instead of printing it to the terminal
Example:
shfmt {{[-w|--write]}} {{path/to/file}}-s, --simplifybooleanSimplify the code, removing redundant pieces of syntax (e.g. removing "$" from vars in expressions)
Example:
shfmt {{[-s|--simplify]}} {{path/to/file}}-i, --indentbooleanSpecify the amount of spaces to use for indentation (0 for tabs, which is also the default)
Example:
shfmt {{[-i|--indent]}} {{4}} {{path/to/file}}--case-indentbooleanFormat the code according to Google's style guide
Example:
shfmt {{[-i|--indent]}} 2 {{[-ci|--case-indent]}} {{[-w|--write]}} {{path/to/file}}Examples (6)
Print a formatted version of a shell script
shfmt path/to/fileList unformatted files
shfmt [-l|--list] path/to/directoryWrite the result to the file instead of printing it to the terminal
shfmt [-w|--write] path/to/fileSimplify the code, removing redundant pieces of syntax (e.g. removing "$" from vars in expressions)
shfmt [-s|--simplify] path/to/fileSpecify the amount of spaces to use for indentation (0 for tabs, which is also the default)
shfmt [-i|--indent] 4 path/to/fileFormat the code according to Google's style guide
shfmt [-i|--indent] 2 [-ci|--case-indent] [-w|--write] path/to/filemade by @shridhargupta | data from tldr-pages