Hi
I have e.g. VAR1=january and I need to change it into VAR1=January.
How to change value of VAR1 variable to always set first character uppercase and other lowercase ?
thx for help.
Hi
I have e.g. VAR1=january and I need to change it into VAR1=January.
How to change value of VAR1 variable to always set first character uppercase and other lowercase ?
thx for help.
echo "$var" | tr -s '[:lower:]' '[:upper:]' | read tmp
var=$tmp
Hi
echo hola | awk '{OFS="";print toupper(substr($1,1,1)),substr($1,2)}'
try this one
echo hello | sed 's/.*/\u&/'
I used advice from jim mcnamara, so :
echo "$var" | tr -s '[:lower:]' '[:upper:]' | read tmp
var=$tmp
But when I call function which uses this mechanism I get such error :
./filterEngine.ksh[11]: February: not found
# cat filterEngine.ksh
#!/bin/ksh
################# Funtion monthGrep() #####################
494 monthGrep()
495 {
496 echo "$Month" | tr -s '[:lower:]' '[:upper:]' | read tmp
497 Month="$tmp"
498 print $Month
499
500 case $Month in
501 STYCZEN)
502 `print January`
503 ;;
504 LUTY)
505 `print "February"`
506 ;;
507 MARZEC)
508 `print March`
509 ;;
510 KWIECIEN)
511 `print April`
512 ;;
513 MAJ)
514 `print May`
515 ;;
516 CZERWIEC)
517 `print June`
518 ;;
519 LIPIEC)
520 `print July`
521 ;;
522 SIERPIEN)
523 `print August`
524 ;;
525 WRZESIEN)
526 `print Septemebr`
527 ;;
528 PAZDZIERNIK)
529 `print October`
530 ;;
531 LISTOPAD)
532 `print November`
533 ;;
534 GRUDZIEN)
535 `print December`
536 ;;
537 *)
538 `print /dev/null`
539 ;;
540 esac
}
#############################################################
print -n " What is the name of the month? "
read Month
monthGrep `print $Month`
thx for help
Hello,
other solution that could be used for other languages is:
Create a file names (i.e) months with the content:
styczen:January
luty:February
marzec:March
...and so on...
then, if in the variable month you have the user entered, you can:
grep -i $month months | cut -d: -f 2
and the result will be the english name...
bash 4
# name=january
# echo ${name^}
January
or..
# name=jAnUaRy
# first=${name:0:1}
# rest=${name:1}
# name=${first^}${rest,,}
# echo $name
January
Yes, agree with other solutions, but when I execute this script I get the following error:
Program asks me to put value, I enter luty.
Then program should print to the screen "February" bu it print the following error :
./filterEngine.ksh[11]: February: not found
What is the problem here ?
the line number of the error is "11"?
this line doesn't appear in the code you've posted.
Hi.
You are executing the result of print February:
$ `print February`
ksh: February: not found.
$ print February
February
Remove the backquotes