From b3e81e0da9262779436a7e28fe6c846b0a0274c1 Mon Sep 17 00:00:00 2001 From: xvazquezc Date: Fri, 5 Jul 2019 15:30:00 +1000 Subject: [PATCH] upper/lowercase manipulation --- bash.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bash.md b/bash.md index 8f63f0e2c..ab61a3a38 100644 --- a/bash.md +++ b/bash.md @@ -199,6 +199,19 @@ comment | `${#FOO}` | Length of `$FOO` | +### Manipulation + +```bash +STR="HELLO WORLD!" +echo ${STR,} #=> "hELLO WORLD!" (lowercase 1st letter) +echo ${STR,,} #=> "hello world!" (all lowercase) + +STR="hello world!" +echo ${STR^} #=> "Hello world!" (uppercase 1st letter) +echo ${STR^^} #=> "HELLO WORLD!" (all uppercase) +``` + + ### Default values | `${FOO:-val}` | `$FOO`, or `val` if not set |