printf
Format and print text. More information: <https://www.gnu.org/software/coreutils/printf>.
Install
- All systems
-
curl cmd.cat/printf.sh
- Debian
-
apt-get install coreutils
- Ubuntu
-
apt-get install coreutils
- Alpine
-
apk add coreutils
- Arch Linux
-
pacman -S coreutils
- Kali Linux
-
apt-get install coreutils
- CentOS
-
yum install coreutils
- Fedora
-
dnf install coreutils
- Windows (WSL2)
-
sudo apt-get update
sudo apt-get install coreutils
- OS X
-
brew install coreutils
- Raspbian
-
apt-get install coreutils
- Dockerfile
- dockerfile.run/printf
- Docker
-
docker run cmd.cat/printf printf
powered by Commando
Format and print text. More information: <https://www.gnu.org/software/coreutils/printf>.
-
Print a text message:
printf "%s\n" "Hello world"
-
Print an integer in bold blue:
printf "\e[1;34m%.3d\e[0m\n" 42
-
Print a float number with the Unicode Euro sign:
printf "\u20AC %.2f\n" 123.4
-
Print a text message composed with environment variables:
printf "var1: %s\tvar2: %s\n" "$VAR1" "$VAR2"
-
Store a formatted message in a variable (does not work on zsh):
printf -v myvar "This is %s = %d\n" "a year" 2016
© tl;dr; authors and contributors