LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 02:10 AM   #1
Volcano
Member
 
Registered: Sep 2005
Posts: 172

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, 02:20 AM   #2
sysmicuser
Member
 
Registered: Mar 2010
Posts: 332

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, 02:32 AM   #3
Volcano
Member
 
Registered: Sep 2005
Posts: 172

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, 02:38 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
man date
/FORMAT



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

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, 02: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, 03:06 AM   #7
Volcano
Member
 
Registered: Sep 2005
Posts: 172

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 03:07 AM.
 
Old 04-22-2012, 03: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, 03:14 AM   #9
Volcano
Member
 
Registered: Sep 2005
Posts: 172

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, 03: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, 03:36 AM   #11
Volcano
Member
 
Registered: Sep 2005
Posts: 172

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 03:43 AM.
 
Old 04-22-2012, 03: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, 03:47 AM   #13
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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, 04:02 AM   #14
Volcano
Member
 
Registered: Sep 2005
Posts: 172

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, 02:57 AM   #15
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

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


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


All times are GMT -5. The time now is 09:53 AM.

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