LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 04-22-2012, 01:10 AM   #1
Volcano
Member
 
Registered: Sep 2005
Posts: 225

Rep: Reputation: 15
date command


$(date +%e-%B-%Y)

what does e , B , Y stands for in this command ?

I guess Y =year

what does e and B stands for ?
 
Old 04-22-2012, 01:20 AM   #2
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Rep: Reputation: 0
The best is to do it yourself on server.

Here is a clue for you.

user01@user01-VirtualBox:~$ date +%e-%B-%Y
22-April-2012
user01@user01-VirtualBox:~$

---------- Post added 04-22-12 at 04:21 PM ----------

or you can look at man page and play with formatting
 
Old 04-22-2012, 01:32 AM   #3
Volcano
Member
 
Registered: Sep 2005
Posts: 225

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by sysmicuser View Post
The best is to do it yourself on server.

Here is a clue for you.

user01@user01-VirtualBox:~$ date +%e-%B-%Y
22-April-2012
user01@user01-VirtualBox:~$

---------- Post added 04-22-12 at 04:21 PM ----------

or you can look at man page and play with formatting
No. you misunderstood my post. I dont want to know its output because I know it. I meant the flag expansion

Quote:
I guess Y =year
what does e and B stands for
Please revert back if you still dont get the point.
 
Old 04-22-2012, 01:38 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
man date
/FORMAT



Cheers,
Tink
 
Old 04-22-2012, 01:54 AM   #5
Volcano
Member
 
Registered: Sep 2005
Posts: 225

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Tinkster View Post
man date
/FORMAT
Cheers,
Tink
thanks I have found these ...
FORMAT controls the output.

%Y year
%e day of month, space padded; same as %_d
%B locale’s full month name (e.g., January)

but why a "+" there in date +%e-%B-%Y

+ is used for String concatenation. I dont see any logic why + is used with date
 
Old 04-22-2012, 01:58 AM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
From the man page:

date [OPTION]... [+FORMAT]

It's just used to tell date that the characters that come after it are the format string.
 
Old 04-22-2012, 02:06 AM   #7
Volcano
Member
 
Registered: Sep 2005
Posts: 225

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Nylex View Post
From the man page:

date [OPTION]... [+FORMAT]

It's just used to tell date that the characters that come after it are the format string.
aah ...[+FORMAT] ....I see there is + before format.

Why Linux developers has kept OPTION and FORMAT both in the manual ? they could just put either. Don't understand why both. How are they different from functional point of view ?

Last edited by Volcano; 04-22-2012 at 02:07 AM.
 
Old 04-22-2012, 02:09 AM   #8
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
FORMAT is for the format string, while OPTION is for options like --date, --reference, etc. Also, date isn't developed by "Linux developers", but by GNU people. Their software is available for other platforms as well.
 
Old 04-22-2012, 02:14 AM   #9
Volcano
Member
 
Registered: Sep 2005
Posts: 225

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Nylex View Post
FORMAT is for the format string, while OPTION is for options like --date, --reference, etc.
Does that mean FORMAT may not be available for other commands ...because all commands may not print and hence no output format required.


But options seems all commands require .
 
Old 04-22-2012, 02:20 AM   #10
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Obviously the arguments you can pass to a given command are specific to that command.
 
Old 04-22-2012, 02:36 AM   #11
Volcano
Member
 
Registered: Sep 2005
Posts: 225

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Nylex View Post
Obviously the arguments you can pass to a given command are specific to that command.
Excellent. I got you. You are very much helpful. Thanks.

Can you please tell how do I print a date

(a) 7 days prior to the current date

(b) last date of the previous month



I'm trying to do this basically...

$ date-7 +%e-%B-%Y // this is not correct syntax I know

Whats the correct syntax here ?


and

$ last_date_of_previous_month+%e-%B-%Y // this is not correct syntax I know

Whats the correct syntax here ?

Last edited by Volcano; 04-22-2012 at 02:43 AM.
 
Old 04-22-2012, 02:45 AM   #12
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Did you look at the documentation for date? This is covered there. From the bottom of the man page:

A date string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers. ... The date string format is more complex than is easily documented here but is fully described in the info documentation.

The "SEE ALSO" section tells you how to get to the info page. Once there, you want to look at the section "Date input formats".
 
Old 04-22-2012, 02:47 AM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
I don't understand what you mean by two, but ...
Code:
 date "+%e-%B-%Y" --date "today - 7 days"
15-April-2012
 
Old 04-22-2012, 03:02 AM   #14
Volcano
Member
 
Registered: Sep 2005
Posts: 225

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Tinkster View Post
I don't understand what you mean by two, but ...
Code:
 date "+%e-%B-%Y" --date "today - 7 days"
15-April-2012
This is OK.

How do I get the last date of the previous month in the same format ?
 
Old 04-23-2012, 01:57 AM   #15
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Quote:
How do I get the last date of the previous month in the same format ?
Did you try looking through the man page of date?
 
  


Reply



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
help in date command mmhs Linux - Newbie 2 12-17-2010 03:37 PM
using date command sumeet inani Linux - Newbie 9 05-06-2010 05:40 AM
date command miran_shahverdyan Linux - General 4 10-14-2009 06:59 AM
command for date DarReNz Solaris / OpenSolaris 7 09-05-2006 09:53 AM
date command aetucker1 Linux - General 3 01-21-2005 12:57 PM

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

All times are GMT -5. The time now is 04:28 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