LinuxQuestions.org
Visit Jeremy's Blog.
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, 08: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, 08:18 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

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

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 05:56 AM.
 
Old 10-12-2014, 11:53 PM   #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, 12:34 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,786

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
| 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, 02: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, 10: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:	621
Size:	5.1 KB
ID:	16641  
 
Old 10-13-2014, 10: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, 12:11 PM   #9
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,485

Rep: Reputation: 2485Reputation: 2485Reputation: 2485Reputation: 2485Reputation: 2485Reputation: 2485Reputation: 2485Reputation: 2485Reputation: 2485Reputation: 2485Reputation: 2485
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 12:13 PM.
 
Old 10-13-2014, 03: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, 03:58 PM   #11
jkirchner
Member
 
Registered: Apr 2007
Location: West Virginia
Distribution: Pop!_OS
Posts: 945

Rep: Reputation: 297Reputation: 297Reputation: 297
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 04:09 PM.
 
1 members found this post helpful.
Old 10-14-2014, 06: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:	241
Size:	3.7 KB
ID:	16648  
 
Old 10-14-2014, 06:57 PM   #13
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
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, 12: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, 01:06 AM   #15
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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 02:44 AM
Display the percentage of increase in data size for each month Bunty2013 Linux - Newbie 2 10-21-2013 12:21 PM
LXer: cal & ncal – Linux Commands To Display Calendar Information LXer Syndicated Linux News 0 07-18-2013 06:40 PM
How to find/display out last Friday's date of the month sunnysthakur Linux - General 11 03-29-2013 03:09 AM
display month format in 2 digit coolplanet Programming 7 06-07-2009 08:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:19 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
Open Source Consulting | Domain Registration