Change date to uppercase


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Change date to uppercase
# 1  
Old 08-26-2008
Change date to uppercase

Hello,

I'm trying to take a 3 character date and change it to uppercase, does anyone know how to do that?

Currently, all commands that I know of for changing strings/variables to uppercase change the command itself to uppercase, not the output.

Here is what I've tried:

date="date +%b"
echo $date
Aug

echo $date | tr "a-z" "A-Z"
DATE +%B
echo "$date" | tr '[a-z]' '[A-Z]'
DATE +%B

OR:
DATE=`echo $date|awk '{print toupper($0)}'`
$DATE
ksh: DATE: not found

OR:
print $date|sed 'y/[a-z]/[A-Z]'
sed: Function y/[a-z]/[A-Z] cannot be parsed.

Does anyone know how to get that date to all CAPS? (as you see above, it currently reads "Aug"...)
# 2  
Old 08-26-2008
Code:
date | tr -s '[:lower:]'  '[:upper:]'

Please consider using the forum search - this same question has been asked several times in the past two weeks.
# 3  
Old 08-26-2008
Thank you Jim! Smilie

I adapted it to $date | tr -s '[:lower:]' '[:upper:]' and it worked - my apologies.

I did try to find the answers, but I see that the phrases I searched on were bad because I couldn't seem to find the threads you referred to. That seems to be a big challenge to finding answers anywhere - getting the lingo right.

I'm trying to figure out how people would search on something like that - "Changing shell variables to uppercase" or something?

The more useful question would probably be: Any advice on good searching methods?

Thanks again, Jim, in advance
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to change existing date to current date in a filename?

Suppose i have a list of files in a directory as mentioned below 1. Shankar_04152019_ny.txt 2. Gopi_shan_03122019_mi.txt 3. Siva_mourya_02242019_nd.txt .. . . . . 1000 . Jiva_surya_02282019_nd.txt query : At one shot i want to modify the above all filenames present in one path with... (4 Replies)
Discussion started by: Shankar455
4 Replies

2. Shell Programming and Scripting

Change the content of files but not change the date

I have 100 files in a directory , all the files have a word "error" and they are created in different date . Now I would like to change the word from "error" to "warning" , and keep the date of the files ( that means do not change the file creation date after change the word ) , can advise what can... (7 Replies)
Discussion started by: ust3
7 Replies

3. Shell Programming and Scripting

Change the content of files but not change the date

I have 100 files in a directory , all the files have a word "error" and they are created in different date . Now I would like to change the word from "error" to "warning" , and keep the date of the files ( that means do not change the file creation date after change the word ) , can advise what can... (0 Replies)
Discussion started by: ust3
0 Replies

4. Shell Programming and Scripting

Change Date Format

Hi Guys, I had a scenario like this.. It seems very silly...dont think it as a home work question.....:) i tried it many ways but i didn't achieve this... start_date=May122011 here i want to change the start_date in to 20110512 start_date=20110512 tell me how can we achive... (5 Replies)
Discussion started by: apple2685
5 Replies

5. Shell Programming and Scripting

Change to uppercase

Hi I have a string(can be mix of upper and lower case) and need the first three chars of the string to be converted to uppercase (4 Replies)
Discussion started by: Northpole
4 Replies

6. UNIX for Dummies Questions & Answers

Change Uppercase to Lowercase with some exceptions

I need to change instances of uppercase to lowercase. The change occurs only when all of the characters are capital letters. For instance, if the following was contained in the file: THE BRIGHT DAY it should be: the bright day However: The BRIGHT day should remain the same. Also, if it were... (3 Replies)
Discussion started by: kcgb20
3 Replies

7. UNIX for Dummies Questions & Answers

Date change to tomorrow

I have this code in a script that says it is calculating current date: cur_date=`date -u +%m/%d/%Y` If the script is run today during the day, it returns 12/11/2008 If the script is run today during the night, it returns 12/12/2008 Why does it return tomorrow's date if it was run at... (2 Replies)
Discussion started by: mkoay
2 Replies

8. UNIX for Dummies Questions & Answers

Move A File With Same Date,don't Change The Desitination Dir Date

Assume, I created one file three years back and I like to move the file to some other directory with the old date (Creation date)? Is it possible? Explain? (1 Reply)
Discussion started by: jee.ku2
1 Replies

9. UNIX for Dummies Questions & Answers

Need to change filenames in a particular directory from lowercase to UPPERCASE

Hi, I need a shell script which changes a bunch of files in a particular directory from lowercase to UPPERCASE. I am not very familiar with shell scripts so a detailed explanation would be greatly appreciated!!!! Thanks ini advance! :) (7 Replies)
Discussion started by: Duke_Lukem
7 Replies

10. UNIX for Advanced & Expert Users

Change date format

I know the command date +"%Y%m%d" can change today's date to digit format as below . $date +"%Y%m%d" 20071217 it works fine . now I want to do it back . If I have a file like below, (in the file , there are three lines, and each line have ; sign , after the ; sign is the date ) , I... (4 Replies)
Discussion started by: ust
4 Replies
Login or Register to Ask a Question