It means there is a glitch in the matrix - agents are coming!
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
Jump to
Showing posts with label print. Show all posts
Showing posts with label print. Show all posts
Easily add colours to bash scripts
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
WHITE="$(tput setaf 7)"
RESET=$WHITE
echo "${RED}An error occurred${RESET}"
echo "${YELLOW}Warning: Be careful${RESET}"
echo "${GREEN}Everything is groovy${RESET}"
(source)
Old, naive way:
GREEN="\[\033[32m\]"
YELLOW="\[\033[33m\]"
RESET="\[\033[0m\]"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
WHITE="$(tput setaf 7)"
RESET=$WHITE
echo "${RED}An error occurred${RESET}"
echo "${YELLOW}Warning: Be careful${RESET}"
echo "${GREEN}Everything is groovy${RESET}"
(source)
Old, naive way:
GREEN="\[\033[32m\]"
YELLOW="\[\033[33m\]"
RESET="\[\033[0m\]"
Sprintf in Java
import java.text.MessageFormat;
int a = 3;
String b = "coders";
System.out.println(
MessageFormat.format("{0} Java {1}.", String.format("%04d", a), b)
);
C printf and scanf format specifiers
Format Specifier | Type |
|---|---|
%d (or %i) | int |
%c | char |
%f | float |
%lf | double |
%s | string |
| %x | hexadecimal |
Subscribe to:
Posts (Atom)