You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Newline using ANSI-C quoting
$ line=$'foo\nbar'
$ printf'<%s>\n'"$line"<foo
bar>
Rationale:
ShellCheck has found a \t, \n or \r in a context where they just become regular letters t, n or r. Most likely, it was intended as a tab, newline or carriage return.
To generate such characters (plus other less common ones including \a, \f and octal escapes) , use printf as in the example. The exception is for newliness that would be stripped by command substitution; in these cases, use a literal quoted newline instead.
Other characters like \z generate a SC1001 info message, as the intent is less certain.
Exceptions:
None.
Related resources:
Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!