Initial commit
This commit is contained in:
60
snippets/toupper.sh
Executable file
60
snippets/toupper.sh
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
string="Hallo Welt!"
|
||||
|
||||
echo ""
|
||||
echo "string: $string"
|
||||
echo ""
|
||||
|
||||
|
||||
# - Bash 4
|
||||
# -
|
||||
echo "______"
|
||||
echo "Bash 4"
|
||||
echo " \${string^^}"
|
||||
echo ""
|
||||
echo "string: ${string^^}"
|
||||
echo ""
|
||||
|
||||
|
||||
# - tr
|
||||
# -
|
||||
echo "______"
|
||||
echo "tr"
|
||||
echo " echo \"\$string\" | tr '[:lower:]' '[:upper:]'"
|
||||
echo ""
|
||||
echo "string: $(echo "$string" | tr '[:lower:]' '[:upper:]')"
|
||||
echo ""
|
||||
|
||||
|
||||
# - awk
|
||||
# -
|
||||
echo "______"
|
||||
echo "awk"
|
||||
echo " echo \"\$string\" | awk '{print toupper(\$0)}'"
|
||||
echo ""
|
||||
echo "string: $(echo "$string" | awk '{print toupper($0)}')"
|
||||
echo ""
|
||||
|
||||
|
||||
# - sed
|
||||
# -
|
||||
echo "______"
|
||||
echo "sed"
|
||||
echo " echo \"\$string\" | sed -e 's/\(.*\)/\U\1/'"
|
||||
echo ""
|
||||
echo " sed -e 's/\(.*\)/\U\1/' <<< \"\$string\""
|
||||
echo ""
|
||||
echo "string: $(echo "$string" | sed -e 's/\(.*\)/\U\1/')"
|
||||
echo "string: $(sed -e 's/\(.*\)/\U\1/' <<< "$string")"
|
||||
echo ""
|
||||
|
||||
|
||||
# - Perl
|
||||
# -
|
||||
echo "______"
|
||||
echo "Perl"
|
||||
echo " echo \"\$string\" | perl -ne 'print uc'"
|
||||
echo ""
|
||||
echo "string: $(echo "$string" | perl -ne 'print uc')"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user