Format and Print Data

From 6bit.ch wiki
Jump to navigation Jump to search

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