How u convert string "hi pravin how are you?" to
"Hi Pravin How Are You?"
Answers were Sorted based on User's Feedback
Answer / nachikethas
use a perl one liner like this
perl -e '$var="hi pravin how are you";@arr=split("
",$var);foreach $wrd(@arr){print ucfirst($wrd)." ";}'
| Is This Answer Correct ? | 8 Yes | 5 No |
Answer / padmakumar
The file "test" contains "hi pravin how are you?".
sed -e "s/^[a-z]/\U&/" -e "s/[[:space:]][a-z]/ \U&/g" test
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / vipul dalwala
echo "hi pravin how are you?" | awk 'BEGIN { ORS = ""
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lower = "abcdefghijklmnopqrstuvwxyz" }
{
for (i = 1; i <= NF; i++) {
FC = substr($i, 1, 1)
if (C = index(lower, FC))
FC = substr(upper, C, 1)
print FC substr($i,2) " "
}
print "\n"
}'
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / saravanan
$line = "hi Praveen How are you";
$line =~ s/\b(\w+)\b/ucfirst($1)/e;
print $line;
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / mahfooz
echo hi praveen how are you | tr ' ' '\n' | perl -n -
e 'print "\u$_"' | tr '\n' ' '
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / manish yadav
echo hi praveen how are you|sed 's/ [a-z]/\U&/g'|sed 's/^[a-
z]/\U&/g'
| Is This Answer Correct ? | 9 Yes | 11 No |
Answer / pravin
Dear amlan Iwant answer which work for any string given.
| Is This Answer Correct ? | 7 Yes | 13 No |
Answer / sonia
Use perl :-)
msg="hi praveen how are you"
msg=`echo $msg | perl -n -e 'print ucfirst(lc);'`
| Is This Answer Correct ? | 4 Yes | 10 No |
Answer / manuswami
echo "hi praveen how are you"|sed -e 's/
[a-z]/\U&/g'\;'s/^[a-z]/\U&/g'
| Is This Answer Correct ? | 9 Yes | 16 No |
Answer / amlan
sed 's/hi pravin how are you?/Hi Pravin How Are You?/g'
filename
| Is This Answer Correct ? | 15 Yes | 26 No |
write a non recursive shell script that accepts any number of arguments and prints them in the reverse order
What is the basic difference you find between a shell script and perl?
Write a shell script in Linux to shift all characters in a file forward by five characters. (Thus “a” becomes “f’”).
2 Answers Ignou, Tripura Info,
Given a file find the count of lines containing the word "abc".
What is shell and shell script?
How can I Debug a shell scripts and Perl scripting?? or How do you debug a shell scripting and perl scripting ( at the compile time error or run time error) in Unix environment ?
What are types of shells?
Can shell script run on windows?
How to customise the other shell?
What happens when you type ls?
What is MUTEX?
Can you write a script to portray how set –x works?