Page 1 of 1

Hello World

Posted: Wed Jul 22, 2020 10:12 pm
by wiak
#!/bin/sh
# Hello by wiak. Created 23Jul2020. Licence MIT - joking ;-)

message="Hello"
you="Jimmy"
many="You Folks"
howmany=3
too_many="all $howmany of you"

echo Hello1
echo "Hello2"
echo "$message"3
echo "Hello${message}"4
echo "Hello5 $many"5

# A Comment
# From man page:
# If the first operand is −n, or if any of the operands contain a
# <backslash> character, the results are implementation-defined.
# ...
# It is not possible to use echo portably across all POSIX systems
# unless both −n (as the first argument) and escape sequences are omitted.
# ...
# The echo utility has not been made obsolescent because of its
# extremely widespread use in historical applications. Conforming
# applications that wish to do prompting without <newline> characters
# or that could possibly be expecting to echo a −n, should use the
# printf utility

printf "Hello6\n"
printf "Hello7 Jemima\n"
printf "Hello8 $you\n"
printf "%s again %s\n" Hello9 Jemima
printf "Hello10 %s\n" "$toomany"

printf "%s all %d of %s\n" Hello11 $howmany "$many"
# but oft-safer to always use quotes:
printf "%s all %d of %s\n" "Hello12" "$howmany" "$many"

you="World"
printf "The last %d greetings of %s:\n" "$howmany" "$message $you tabbed"

printf "Hello %s\t" World
printf "Hello %s\t" "$you"
printf "%s %s\n" "$message" "$you"