echo Output
echo instruction for the output of a string
Format: Echo string
Direct output String: string
Echo ' This is String-output '
In double quotes, you can also omit quotes here.
Escape character: \
echo ' \ ' It is ok\ '
Variable: \value
Echo ' \value It is value '
Line break: \ n
Echo-e ' This is \ n OK '
-E Open Escape
No newline: \c
Echo-e ' This is \c OK '
Results directed to file: >file
Echo ' This is file ' >file
Output a string as is, without escaping or taking variables: single quotes
Echo ' \name\ '
Command execution result: anti-quote '
Echo ' Date '
Single quotes cannot reference variables, transfer characters, and text formatting symbols (newline, tab)
Double quotes can refer to variables, transfer characters, and text formatting symbols (newline, tab)
No reference to variables, transfer characters, but not text format symbols (newline, tab)
printf output
printf uses reference text or space-delimited parameters, which can be used outside of the format string in printf, as well as the width of the string, left and right alignment, etc.
Format: printf format-string [parameter list]
printf "%d%s\n" "Test"
Here single quotes, double quotes, no quotation marks are possible
Escape sequences for printf
\a Warning Character
\b Back
\f Page Change
\ nthe line break
\ r Enter
\ t Horizontal tab
\v Vertical Tab
\ \ A literal backslash character
The \DDD represents a 1 to 3-digit octal value character. Valid only in format strings
\0DDD represents 1 to 3-bit octal value characters
printf format symbols
%d:decimal decimal Integer
%s:string string
%c:char characters
%f:float floating Point
printf Practice
、
%-10s refers to a width of 10 characters (-left aligned, no right-aligned) less than 10 characters are filled with spaces, and the contents are displayed in full
%-4.2F refers to the format of decimals, where. 2 means reserved 2 decimal places
Results:
Shell Programming-Output (vi)