Monday, July 16, 2012
10:00 PM

Bash Script: Convert String Toupper and Tolower

Here is a simple bash script which converts the given string to upper or to lower case.
feel free to copy and use this script:


Source:
cat toupper_tolower.sh
#!/bin/bash

echo -n "Enter the String: "
read String

echo -n "Only First characters to uppercase: "
echo ${String^}

echo -n "All characters to uppercase: "
echo ${String^^}

echo -n "Only First characters to Lowercase: "
echo ${String,}

echo -n "All characters to lowercase: "
echo ${String,,}


Output:
./toupper_tolower.sh
Enter the String: linuXPoisoN
Only First characters to uppercase: LinuXPoisoN
All characters to uppercase: LINUXPOISON
Only First characters to Lowercase: linuXPoisoN
All characters to lowercase: linuxpoison


0 comments:

Post a Comment