Difference between revisions of "Format and Print Data"

From 6bit.ch wiki
Jump to navigation Jump to search
(Created page with "= printf = Print ARGUMENT(S) according to FORMAT, or execute according to OPTION.</br> <code>printf FORMAT [ARGUMENT]</code></br> <code>printf OPTION</code></br> FORMAT controls the output as in C printf. Interpreted sequences are:</br> <code>\n</code> new line</br> <code>%s</code> output as string</br> <code>%d</code> output as integer</br> Example:</br> <code>printf '%s\n' yolo</code>")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
= printf =
= printf =
Print ARGUMENT(S) according to FORMAT, or execute according to OPTION.</br>
Print ARGUMENT(S) according to FORMAT, or execute according to OPTION.</br>
== Use ==


<code>printf FORMAT [ARGUMENT]</code></br>
<code>printf FORMAT [ARGUMENT]</code></br>
Line 11: Line 13:


Example:</br>
Example:</br>
<code>printf '%s\n' yolo</code>
<code>printf '%s\n' 'yolo'</code>
 
== List files with printf ==
<code>printf "%s\n" *</code> display files and directories in the current directory</br>
<code>printf "%s\n" */</code> display directories in the current directory</br>
<code>printf "%s\n" *.{jpg,jpeg,png}</code> display (some) images only</br>

Latest revision as of 17:41, 17 March 2023

printf

Print ARGUMENT(S) according to FORMAT, or execute according to OPTION.

Use

printf FORMAT [ARGUMENT]
printf OPTION

FORMAT controls the output as in C printf. Interpreted sequences are:
\n new line
%s output as string
%d output as integer

Example:
printf '%s\n' 'yolo'

List files with printf

printf "%s\n" * display files and directories in the current directory
printf "%s\n" */ display directories in the current directory
printf "%s\n" *.{jpg,jpeg,png} display (some) images only