LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-11-2014, 09:11 PM   #1
hello111
LQ Newbie
 
Registered: Oct 2014
Posts: 9

Rep: Reputation: Disabled
Talking How to display the current month using cal


Hello, I got stuck in a question "Display the current month using 'cal', translating to uppercase using 'tr'.". Please help me
 
Old 10-11-2014, 09:18 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
See the "description line in 'man cal' and search 'man tr' for "upper"?
 
Old 10-12-2014, 06:53 AM   #3
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,464

Rep: Reputation: Disabled
This sounds like homework. Please show the commands you tried and what error messages (if any) you received. Also "translating to uppercase" is not at all clear. Translating what? The name of the month? The abbreviated days of the week? What?

And in the future please use a more descriptive thread title than "Please help me". Something like "Displaying calendar using the cal command" would give a better idea of what your problem is.
jdk

Last edited by jdkaye; 10-12-2014 at 06:56 AM.
 
Old 10-13-2014, 12:53 AM   #4
hello111
LQ Newbie
 
Registered: Oct 2014
Posts: 9

Original Poster
Rep: Reputation: Disabled
Thanks you guys. It's my homework, yes. My command was like : cal | tr 'a-z' 'A-Z', it didn't work and the hint is: use | command.
 
Old 10-13-2014, 01:34 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
| is already in use (as I see), there should be something else too... Probably see the man page of cal, and try to find out how to display exactly what you need.
 
Old 10-13-2014, 03:22 AM   #6
nisagnel
LQ Newbie
 
Registered: Mar 2010
Location: India
Distribution: Centos
Posts: 28

Rep: Reputation: 2
Hello hello111,

If you want to display only current month you can go for date command like below.
date +%B | tr 'a-z' 'A-Z'

If you want the whole month calender with upper case month,then ur command "cal | tr 'a-z' 'A-Z'" works fine.
 
Old 10-13-2014, 11:04 AM   #7
hello111
LQ Newbie
 
Registered: Oct 2014
Posts: 9

Original Poster
Rep: Reputation: Disabled
Smile

Here is the question and the hint. Thanks you guys for helping me.
Attached Thumbnails
Click image for larger version

Name:	lol.png
Views:	188
Size:	5.1 KB
ID:	16641  
 
Old 10-13-2014, 11:09 AM   #8
hello111
LQ Newbie
 
Registered: Oct 2014
Posts: 9

Original Poster
Rep: Reputation: Disabled
Tks nisagnel, I try your comment but it didn't work
 
Old 10-13-2014, 01:11 PM   #9
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 6,872

Rep: Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249
Quote:
cal | tr 'a-z' 'A-Z', it didn't work
Don't know why that didn't work, it worked for me. Not sure really what you are expecting.

Last edited by yancek; 10-13-2014 at 01:13 PM.
 
Old 10-13-2014, 04:46 PM   #10
hello111
LQ Newbie
 
Registered: Oct 2014
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by yancek View Post
Don't know why that didn't work, it worked for me. Not sure really what you are expecting.
I don't know to but it didn't work
 
Old 10-13-2014, 04:58 PM   #11
jkirchner
Member
 
Registered: Apr 2007
Location: West Virginia
Distribution: LinuxMint 18
Posts: 747

Rep: Reputation: 182Reputation: 182
What do you think it is supposed to do? All the days of the week are capitalized as is the name of the month. That is what that line does.

The code produces (note the month and the days of the week are capitalized):
This is what I entered:
Code:
cal | tr 'a-z' 'A-Z'
Code:
    OCTOBER 2014      
SU MO TU WE TH FR SA  
          1  2  3  4  
 5  6  7  8  9 10 11  
12 13 14 15 16 17 18  
19 20 21 22 23 24 25  
26 27 28 29 30 31
regular cal does:

Code:
    October 2014      
Su Mo Tu We Th Fr Sa  
          1  2  3  4  
 5  6  7  8  9 10 11  
12 13 14 15 16 17 18  
19 20 21 22 23 24 25  
26 27 28 29 30 31
What do you think it should do? When you type the code I did what is the output?

Last edited by jkirchner; 10-13-2014 at 05:09 PM.
 
1 members found this post helpful.
Old 10-14-2014, 07:24 PM   #12
hello111
LQ Newbie
 
Registered: Oct 2014
Posts: 9

Original Poster
Rep: Reputation: Disabled
Here is my work, I did try use a command cal | tr 'a-z' 'A-Z' but it seem didn't work
Attached Thumbnails
Click image for larger version

Name:	2.PNG
Views:	114
Size:	3.7 KB
ID:	16648  
 
Old 10-14-2014, 07:57 PM   #13
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 806

Rep: Reputation: 186Reputation: 186
The response from the system "You entered ..." shows that you are within your structured question bank environment and not the shell. Two things to do:
1) Try cal 10 2014 | tr ... within your environment and
2) Go to a regular shell prompt and enter cal | tr ... and so on.

Option 2) should work. If option 1) works with year and month as arguments, go tell your examiner to improve the test bank.

OK
 
1 members found this post helpful.
Old 10-15-2014, 01:37 AM   #14
nisagnel
LQ Newbie
 
Registered: Mar 2010
Location: India
Distribution: Centos
Posts: 28

Rep: Reputation: 2
Cool

Hi hello111,

What AnanthaP suggests, is right.

Also if you want only upper case month from cal command,type the following command in your shell(if you type in somewhere,definetely it won't work).

[root@localhost]# cal | head -n1 | awk '{print $1}' | tr 'a-z' 'A-Z'
OCTOBER

is that you want?
 
1 members found this post helpful.
Old 10-15-2014, 02:06 AM   #15
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

why do you think 'a-z' and 'A-Z' are valid? As already pointed out, check the man page of tr.

Evo2.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware64 --current (XFCE) - Laptop + external display, enabling disabled display slaka Slackware 0 11-03-2013 03:44 AM
Display the percentage of increase in data size for each month Bunty2013 Linux - Newbie 2 10-21-2013 01:21 PM
LXer: cal & ncal Linux Commands To Display Calendar Information LXer Syndicated Linux News 0 07-18-2013 07:40 PM
How to find/display out last Friday's date of the month sunnysthakur Linux - General 11 03-29-2013 04:09 AM
display month format in 2 digit coolplanet Programming 7 06-07-2009 09:55 PM


All times are GMT -5. The time now is 08:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration