How to output first character of a word in capital?
Kindly consider:
Code:
-bash-2.05b# echo $v | tr [a-z] [A-Z] Code:
Hello In fact, I am doing this: Code:
echo "Welcome, $USER!" Code:
-bash-2.05b# ./welcome.sh Any ideas? |
If you want to use commands like tr, then you can do this:
Code:
echo $USER | head -c 1 | tr [a-z] [A-Z]; echo $USER | tail -c +2 Code:
perl -e "print ucfirst($USER)" |
Try this:
Code:
#!/bin/bash |
This doesn't yeild the desired result:
Code:
Hey, this does one works! Code:
-bash-2.05b# perl -e "print ucfirst($USER)" Thanks buddy! Quote:
|
After running the script I get this error:
Code:
-bash-2.05b# cat cap.sh Quote:
By the way, thanks to you! |
"${VARIABLE^}" is a new bash version 4 substitution. It doesn't exist in previous releases.
The OP's prompt shows that he's using bash 2.05, so it naturally won't work for him. But it does lead to the question as to why he's running such an old version. |
All times are GMT -5. The time now is 08:15 PM. |