I created this repo to keep track of extremely useful scripts and to hopefully add some benefit to others. Please feel free to fork / contribute.
Asks a question and echoes the user input.
Asks a yes/no question and echoes true or false. It will continue to ask
the user for input until they respond with one of the folllwing: y, yes,
n or no.
Replaces all uppercase letters with their lowercase counterparts.
#!/bin/bash
echo "Hello Motto" | downcase
# => hello mottoThis is a simple abstraction that wraps echo, higlights text in red and is redirected to stderr.
This is identical to err_msg except that it exits 1 after echoing the error message.
Removes all leading whitespace. See also rstrip and strip.
#!/bin/bash
echo " Hello Motto" | lstrip
# => Hello MottoThis is a simple abstraction that wraps echo.
Removes all trailing whitespace. See also lstrip and strip.
#!/bin/bash
echo "Hello Motto " | rstrip
# => Hello MottoRemoves all leading and trailing whitespace.
Whitespace is defined as any of the following characters: null, horizontal tab, line feed, vertical tab, form feed, carriage return, space.
#!/bin/bash
echo " Hello Motto " | strip
# => Hello MottoEchoes success! or failed! based on $?.
Replaces all lowercase letters with their uppercase counterparts.
#!/bin/bash
echo "Hello Motto" | upcase
# => HELLO MOTTO