perl -e '$HOSTNAME = `hostname -s`; print $HOSTNAME;' | od -c
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 non-printable. Show all posts
Showing posts with label non-printable. 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\]"
Find dodgy characters in a file
This will print any characters with values higher than 127, i.e. non-ascii characters that might look like ascii, but really be breaking your processor.
perl -lne'while (my ($c) = $_ =~ m{^(.)}) { print "$c = ".ord($c) if ord($c) > 127; $_ =~ s/^.// }' file_to_check.something
A quick, manual way to confirm some characters really are what you think they are:
cat file_to_check.something | od -bc
perl -lne'while (my ($c) = $_ =~ m{^(.)}) { print "$c = ".ord($c) if ord($c) > 127; $_ =~ s/^.// }' file_to_check.something
A quick, manual way to confirm some characters really are what you think they are:
cat file_to_check.something | od -bc
Labels:
ascii,
characters,
dodgy,
encoding,
non-printable,
one-liner,
perl,
utf8
Insert non-printable characters in vi
- Ctrl-V, then Ctrl-[X]
Labels:
characters,
non-printable,
text editor,
vi
Show/hide invisible/non-printable characters in Outlook (and probably Word)
Control-Shift-8
Labels:
annoying,
characters,
email,
non-printable,
outlook,
word
Subscribe to:
Posts (Atom)